From 20798fcb276589ca9b6f5eef30c21cbb1831bcb8 Mon Sep 17 00:00:00 2001 From: Alexandr Abramov Date: Wed, 27 Sep 2023 20:08:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=B5=20is=5Factive=5Fsale=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20Product?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- products/admin.py | 2 +- products/models.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/products/admin.py b/products/admin.py index 040a4ed..5a7d64a 100644 --- a/products/admin.py +++ b/products/admin.py @@ -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', ) diff --git a/products/models.py b/products/models.py index 7687221..9fa9a5c 100644 --- a/products/models.py +++ b/products/models.py @@ -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