class Category MPTTModel parent TreeForeignKey self null True blank Tr

 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class Category(MPTTModel):
parent = TreeForeignKey('self', null=True, blank=True, related_name='children', verbose_name=u'Родитель')
name = models.CharField(verbose_name=u'Название', max_length=250)
title = models.CharField(verbose_name=u'Title', max_length=250, blank=True)
url = models.CharField(verbose_name=u'URL', max_length=250, editable=False, unique=True)
slug = models.SlugField(verbose_name=u'Slug')
for_descript = models.TextField(verbose_name=u'4descript', blank=True)
icon = ImageField(verbose_name=u'Иконка', upload_to=upload_dir, blank=True)
icon_hover = ImageField(verbose_name=u'Иконка при наведении', upload_to=upload_dir, blank=True)
description = models.TextField(verbose_name=u'Описание', blank=True)
seo = models.TextField(verbose_name=u'SEO', blank=True)
position = models.IntegerField(verbose_name=u'Позиция', default=1000, max_length=4, db_index=True)
active = models.BooleanField(verbose_name=u'Публиковать', default=True, db_index=True)
menu = models.BooleanField(verbose_name=u'Отображать в главном меню', default=True, db_index=True)
modified = models.DateTimeField(u"Изменен", default=datetime.datetime.now, auto_now=True)
class MPTTMeta:
order_insertion_by = ['position']
class Meta:
ordering = ['position']
verbose_name = u'Категория'
verbose_name_plural = u'Категории'
class Product(models.Model):
RATING = [(0, 0), (1, 1), (2, 3), (3, 3), (4, 4), (5, 5)]
TYPES = [
(1, u'Акция'),
(2, u'Новинка'),
(3, u'Ликвидация'),
(4, u'Хит'),
]
category = models.ForeignKey(Category, verbose_name=u'Категория')
brand = models.ForeignKey(Brand, verbose_name=u'Бренд')
name = models.CharField(verbose_name=u'Название', max_length=250)
slug = models.SlugField(verbose_name=u'Slug', unique=True)
description = models.TextField(verbose_name=u'Описание', blank=True)
complect = models.TextField(verbose_name=u'Комплектация', blank=True)
video = models.CharField(verbose_name=u'Видео', max_length=250, blank=True, help_text=u'HTML-код для вставки видео')
position = models.IntegerField(verbose_name=u'Позиция', default=1000, max_length=4, db_index=True)
rating = models.IntegerField(verbose_name=u'Рейтинг', default=0, choices=RATING)
yandex = models.BooleanField(verbose_name=u'Яндекс-маркет', default=True, db_index=True)
available = models.BooleanField(verbose_name=u'Наличие', default=True, editable=False) # временно отключаем, потом удалим
type = models.IntegerField(verbose_name=u'Тип товара', blank=True, null=True, choices=TYPES)
popular = models.BooleanField(verbose_name=u'Популярный', default=False)
photo = models.ImageField(verbose_name=u'Фото', upload_to=upload_dir, blank=True, editable=False)
price = models.FloatField(verbose_name=u'Цена', default=0, editable=False)
price_old = models.FloatField(verbose_name=u'Старая цена', blank=True, null=True, editable=False)
active = models.BooleanField(verbose_name=u'Публиковать', default=True, db_index=True)
created = models.DateTimeField(u"Создан", default=datetime.datetime.now, editable=False)
modified = models.DateTimeField(u"Изменен", default=datetime.datetime.now, auto_now=True)
class Meta:
ordering = ['position']
verbose_name = u'Продукт'
verbose_name_plural = u'Продукты'