Spaces:
Sleeping
Sleeping
from django.db import models | |
from django.db import connection | |
# Create your models here. | |
class Products(models.Model): | |
name = models.CharField(max_length=500, unique=True) | |
score = models.IntegerField(null=True) | |
image = models.CharField(max_length=5000) | |
propGroupsMini = models.JSONField(default=dict) | |
propScore = models.JSONField() | |
category = models.ForeignKey('Categories', on_delete=models.CASCADE, null=True) | |
link = models.CharField(max_length=500,default="") | |
terms = models.JSONField(default=dict) | |
suggestions = models.JSONField(default=dict) | |
tldr = models.JSONField(default=dict) | |
propGroups = models.JSONField(default=dict) | |
notApplicableProps = models.JSONField(default=dict) | |
cheapAlternatives = models.JSONField(default=dict) | |
topProps = models.JSONField(default=dict) | |
popularCompare = models.JSONField(default=dict) | |
toplist = models.JSONField(default=dict) | |
def __str__(self): | |
return self.name | |
# @classmethod | |
# def truncate(cls): | |
# with connection.cursor() as cursor: | |
# cursor.execute( | |
# 'TRUNCATE TABLE {} CASCADE'.format(cls._meta.db_table)) | |
class Categories(models.Model): | |
name = models.CharField(max_length=1000, unique=True) | |
link = models.CharField(max_length=1000) | |
def __str__(self): | |
return self.name | |