product model update
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.2 on 2025-02-01 18:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0009_productmodel_related_products'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='productmodel',
|
||||
name='related_products',
|
||||
field=models.ManyToManyField(blank=True, null=True, to='product.productmodel'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,24 @@
|
||||
# Generated by Django 5.1.2 on 2025-02-01 23:47
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0010_alter_productmodel_related_products'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='productmodel',
|
||||
name='category',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='products', to='product.subcategorymodel', verbose_name='دسته بندی محصول'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='productmodel',
|
||||
name='related_products',
|
||||
field=models.ManyToManyField(blank=True, to='product.productmodel'),
|
||||
),
|
||||
]
|
||||
@@ -110,8 +110,8 @@ class ProductModel(models.Model):
|
||||
meta_keywords = models.CharField(max_length=300, blank=True, null=True, help_text='این فیلد را حتما پر کنید')
|
||||
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='دسته بندی محصول')
|
||||
related_products = models.ManyToManyField('self',)
|
||||
category = models.ForeignKey(SubCategoryModel, null=True, on_delete=models.SET_NULL, related_name='products', verbose_name='دسته بندی محصول')
|
||||
related_products = models.ManyToManyField('self', blank=True,)
|
||||
def format_discount_price(self):
|
||||
discount_price = int(self.price * (100 - self.discount) / 100)
|
||||
formatted_num = "{:,.0f}".format(discount_price)
|
||||
@@ -156,7 +156,7 @@ class InStuckColors(models.Model):
|
||||
verbose_name = 'تعداد موجود رنگ'
|
||||
verbose_name_plural = 'تعداد موجود رنگ ها'
|
||||
def __str__(self):
|
||||
return f'{product} - {color}'
|
||||
return f'{self.product} - {self.color}'
|
||||
|
||||
class CommentModel(models.Model):
|
||||
product = models.ForeignKey(ProductModel, on_delete=models.CASCADE, related_name='comments', verbose_name='محصول')
|
||||
|
||||
Reference in New Issue
Block a user