File size: 806 Bytes
0bd6e09
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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