udpate product detail name filed
This commit is contained in:
@@ -268,6 +268,11 @@ UNFOLD = {
|
||||
"icon": "photo_prints",
|
||||
"link": reverse_lazy("admin:product_productvariant_changelist"),
|
||||
},
|
||||
{
|
||||
"title": _("بخش جزيیات محصول"),
|
||||
"icon": "subject",
|
||||
"link": reverse_lazy("admin:product_productdetailmodel_changelist"),
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from django.contrib import admin, messages
|
||||
from product.tasks import update_prices
|
||||
from .models import *
|
||||
from unfold.admin import TabularInline, StackedInline
|
||||
from home.models import LearnVideoModel
|
||||
@@ -122,7 +123,7 @@ class DetailModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
class ProductDetailModel1Admin(ModelAdmin, ImportExportModelAdmin):
|
||||
import_form_class = ImportForm
|
||||
export_form_class = ExportForm
|
||||
search_fields = ['detail_category__title']
|
||||
search_fields = ['detail_category__title', 'name']
|
||||
compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
|
||||
@@ -216,8 +217,7 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
|
||||
@action(description=f"اپدیت قیمت ها")
|
||||
def update_products_price(self, request):
|
||||
print('from the button')
|
||||
ProductVariant.update_all_prices()
|
||||
# update_prices()
|
||||
messages.success(request, f"قیمت {ProductVariant.objects.all().count()} تنوع محصول اپدیت شد")
|
||||
return redirect("admin:product_productmodel_changelist")
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.1.2 on 2025-04-21 23:37
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0036_alter_productdetailmodel_detail_category'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='productdetailmodel',
|
||||
name='name',
|
||||
field=models.CharField(default=1, help_text='این متن فقط برای راحتی در استفاده از پنل ادمین میباشد', max_length=50, verbose_name='نام جزيیات'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
@@ -213,6 +213,7 @@ class ProductImageModel(models.Model):
|
||||
|
||||
|
||||
class ProductDetailModel(models.Model):
|
||||
name = models.CharField(max_length=50, verbose_name='نام جزيیات', help_text='این متن فقط برای راحتی در استفاده از پنل ادمین میباشد')
|
||||
detail_category = models.ForeignKey(ProductDetailCategory, on_delete=models.CASCADE, verbose_name='دسته بندی جزيات')
|
||||
detail = models.ManyToManyField(DetailModel, verbose_name='جزيات ها')
|
||||
|
||||
@@ -220,7 +221,7 @@ class ProductDetailModel(models.Model):
|
||||
verbose_name = 'جزیات محصول'
|
||||
verbose_name_plural = 'جزیات محصول ها'
|
||||
def __str__(self):
|
||||
return f'جزيیات محصول {self.detail_category.title}'
|
||||
return f'جزيیات محصول {self.detail_category.title} - {self.name}'
|
||||
|
||||
class ProductVariant(models.Model):
|
||||
product = models.ForeignKey(ProductModel, on_delete=models.CASCADE, related_name='variants', verbose_name='محصول')
|
||||
|
||||
Reference in New Issue
Block a user