Skip to content

Commit

Permalink
Добавил поле is_active_sale для модели Product
Browse files Browse the repository at this point in the history
  • Loading branch information
Abramov0Alexandr committed Sep 27, 2023
1 parent bd16e1b commit 20798fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion products/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

@admin.register(Product)
class UserAdmin(admin.ModelAdmin):
list_display = ('id', 'shop_name', 'product_title', 'seller', 'price', )
list_display = ('id', 'shop_name', 'product_title', 'seller', 'price', 'is_active_sale', )
list_display_links = ('product_title', )
6 changes: 6 additions & 0 deletions products/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ class Product(models.Model):
Модель для хранения информации о товаре.
"""

SALE_STATUS = [
(True, 'В продаже'),
(False, 'Снят с продажи')
]

product_title = models.CharField(max_length=255, verbose_name='Наименование товара')
seller = models.ForeignKey(get_user_model(), on_delete=models.PROTECT, related_name='seller', verbose_name='Продавец')
price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='Цена товара')
is_active_sale = models.BooleanField(default=True, choices=SALE_STATUS, verbose_name='Статус товара')

objects = models.Manager

Expand Down

0 comments on commit 20798fc

Please sign in to comment.