realted product
This commit is contained in:
@@ -23,7 +23,8 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
export_form_class = ExportForm
|
||||
inlines = [InStuckColorsInLine]
|
||||
readonly_fields = ('slug', )
|
||||
|
||||
search_fields = ['name']
|
||||
autocomplete_fields = ['related_products']
|
||||
compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.2 on 2025-02-01 16:57
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0008_remove_productmodel_color_alter_instuckcolors_color'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='productmodel',
|
||||
name='related_products',
|
||||
field=models.ManyToManyField(to='product.productmodel'),
|
||||
),
|
||||
]
|
||||
@@ -111,7 +111,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='دسته بندی محصول')
|
||||
|
||||
related_products = models.ManyToManyField('self',)
|
||||
def format_discount_price(self):
|
||||
discount_price = int(self.price * (100 - self.discount) / 100)
|
||||
formatted_num = "{:,.0f}".format(discount_price)
|
||||
|
||||
Reference in New Issue
Block a user