refactored a little model Product
This commit is contained in:
parent
0610075706
commit
df38afa36b
|
|
@ -10,8 +10,8 @@ class ProductAdmin(BaseModelAdminMixin, admin.ModelAdmin):
|
|||
search_fields = ('name', )
|
||||
list_filter = ('available', 'product_type')
|
||||
list_display = ('id', '__str__', 'get_category_display', 'product_type')
|
||||
raw_id_fields = ('country', 'subtypes', 'classifications',
|
||||
'standards', 'tags', 'gallery')
|
||||
raw_id_fields = ('subtypes', 'classifications', 'standards',
|
||||
'tags', 'gallery')
|
||||
|
||||
|
||||
@admin.register(ProductType)
|
||||
|
|
|
|||
33
apps/product/migrations/0010_auto_20191111_1227.py
Normal file
33
apps/product/migrations/0010_auto_20191111_1227.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Generated by Django 2.2.7 on 2019-11-11 12:27
|
||||
|
||||
from django.db import migrations, models
|
||||
import utils.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0009_auto_20191111_0731'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='product',
|
||||
name='country',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='available',
|
||||
field=models.BooleanField(default=True, verbose_name='available'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='description',
|
||||
field=utils.models.TJSONField(blank=True, default=None, help_text='{"en-GB":"some text"}', null=True, verbose_name='description'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='slug',
|
||||
field=models.SlugField(max_length=255, null=True, unique=True, verbose_name='Slug'),
|
||||
),
|
||||
]
|
||||
|
|
@ -141,11 +141,9 @@ class Product(TranslatedFieldsMixin, BaseAttributes):
|
|||
name = models.CharField(max_length=255,
|
||||
default=None, null=True,
|
||||
verbose_name=_('name'))
|
||||
description = TJSONField(_('Description'), null=True, blank=True,
|
||||
description = TJSONField(_('description'), null=True, blank=True,
|
||||
default=None, help_text='{"en-GB":"some text"}')
|
||||
country = models.ManyToManyField('location.Country',
|
||||
verbose_name=_('Country'))
|
||||
available = models.BooleanField(_('Available'), default=True)
|
||||
available = models.BooleanField(_('available'), default=True)
|
||||
product_type = models.ForeignKey(ProductType, on_delete=models.PROTECT,
|
||||
null=True,
|
||||
related_name='products', verbose_name=_('Type'))
|
||||
|
|
@ -177,7 +175,7 @@ class Product(TranslatedFieldsMixin, BaseAttributes):
|
|||
blank=True, null=True,
|
||||
verbose_name=_('wine appellation'))
|
||||
slug = models.SlugField(unique=True, max_length=255, null=True,
|
||||
verbose_name=_('Establishment slug'))
|
||||
verbose_name=_('Slug'))
|
||||
favorites = generic.GenericRelation(to='favorites.Favorites')
|
||||
old_id = models.PositiveIntegerField(_('old id'), default=None,
|
||||
blank=True, null=True)
|
||||
|
|
@ -195,6 +193,7 @@ class Product(TranslatedFieldsMixin, BaseAttributes):
|
|||
validators=[MinValueValidator(EARLIEST_VINTAGE_YEAR),
|
||||
MaxValueValidator(LATEST_VINTAGE_YEAR)])
|
||||
gallery = models.ManyToManyField('gallery.Image', through='ProductGallery')
|
||||
reviews = generic.GenericRelation(to='review.Review')
|
||||
|
||||
objects = ProductManager.from_queryset(ProductQuerySet)()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user