diff --git a/backend/product/models.py b/backend/product/models.py index b0a9dd6..0c9af20 100644 --- a/backend/product/models.py +++ b/backend/product/models.py @@ -109,6 +109,7 @@ class ProductModel(models.Model): meta_rating = models.FloatField(default=5, help_text='امتیاز محصول') created_at = models.DateTimeField(auto_now_add=True, verbose_name='زمان ثبت محصول') category = models.ForeignKey(SubCategoryModel, blank=True, null=True, on_delete=models.SET_NULL, related_name='products', verbose_name='دسته بندی محصول') + def format_discount_price(self): discount_price = int(self.price * (100 - self.discount) / 100) formatted_num = "{:,.0f}".format(discount_price) @@ -140,6 +141,10 @@ class ProductModel(models.Model): self.slug = slugify(self.name, allow_unicode=True) super().save(*args, **kwargs) + class Meta: + verbose_name = 'محصول' + verbose_name_plural = 'محصولات' + class CommentModel(models.Model): product = models.ForeignKey(ProductModel, on_delete=models.CASCADE, related_name='comments', verbose_name='محصول')