admin display image
This commit is contained in:
+19
-19
@@ -154,7 +154,7 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
|||||||
autocomplete_fields = ['related_products', ]
|
autocomplete_fields = ['related_products', ]
|
||||||
# compressed_fields = True
|
# compressed_fields = True
|
||||||
warn_unsaved_form = True
|
warn_unsaved_form = True
|
||||||
list_display = ['display_price', 'view', 'show', 'rating', 'category', ]
|
list_display = ['display_image', 'display_price', 'view', 'show', 'rating', 'category', ]
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
('فیلد های اصلی', {'fields': ('name', 'description', 'category', 'related_products', 'show',), "classes": ["tab"],}),
|
('فیلد های اصلی', {'fields': ('name', 'description', 'category', 'related_products', 'show',), "classes": ["tab"],}),
|
||||||
('فیلد های سيو', {'fields': ('meta_description', 'meta_keywords', 'meta_rating', 'slug'), "classes": ["tab"],}),
|
('فیلد های سيو', {'fields': ('meta_description', 'meta_keywords', 'meta_rating', 'slug'), "classes": ["tab"],}),
|
||||||
@@ -176,24 +176,24 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
|||||||
return obj.get_toman_price()
|
return obj.get_toman_price()
|
||||||
display_price.short_description = 'قیمت تومانی'
|
display_price.short_description = 'قیمت تومانی'
|
||||||
|
|
||||||
# @display(description='محصول', header=True)
|
@display(description='محصول', header=True)
|
||||||
# def display_image(self, instance):
|
def display_image(self, instance):
|
||||||
# if instance and instance.variants.first() and instance.variants.first().attributes.first():
|
if instance and instance.variants.first() and instance.variants.first().images.first():
|
||||||
# image = instance.variants.first().attributes.first().image.url if instance.variants.first().attributes.first().image else None
|
image = instance.variants.first().images.first().image.url if instance.variants.first().images.first().image else None
|
||||||
# else:
|
else:
|
||||||
# image = None
|
image = None
|
||||||
# return [
|
return [
|
||||||
# instance.name,
|
instance.name,
|
||||||
# None,
|
None,
|
||||||
# None,
|
None,
|
||||||
# {
|
{
|
||||||
# "path": image,
|
"path": image,
|
||||||
# "height": 30,
|
"height": 30,
|
||||||
# "width": 30,
|
"width": 30,
|
||||||
# "borderless": True,
|
"borderless": True,
|
||||||
# # "squared": True,
|
# "squared": True,
|
||||||
# },
|
},
|
||||||
# ]
|
]
|
||||||
# @display(
|
# @display(
|
||||||
# description=("نمایش در صفحه ی اصلی"),
|
# description=("نمایش در صفحه ی اصلی"),
|
||||||
# label={
|
# label={
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Generated by Django 5.1.2 on 2025-02-12 15:01
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('product', '0022_productimagemodel_remove_attributevalue_color_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='productimagemodel',
|
||||||
|
options={'verbose_name': 'عکس محصولات', 'verbose_name_plural': 'عکس های محصولات'},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='detailmodel',
|
||||||
|
name='detail_text2',
|
||||||
|
field=models.CharField(blank=True, max_length=150, null=True, verbose_name='متن جزیات ۲'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='detailmodel',
|
||||||
|
name='detail_text3',
|
||||||
|
field=models.CharField(blank=True, max_length=150, null=True, verbose_name='متن جزیات ۳'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='detailmodel',
|
||||||
|
name='detail_text4',
|
||||||
|
field=models.CharField(blank=True, max_length=150, null=True, verbose_name='متن جزیات ۴'),
|
||||||
|
),
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user