procom / main /models.py
thejagstudio's picture
Upload 185 files
0bd6e09
raw
history blame
806 Bytes
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)
propGroups = models.JSONField()
propScore = models.JSONField()
category = models.CharField(max_length=500)
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