update admin and image for product image

This commit is contained in:
Parsa Nazer
2025-10-20 18:56:48 +03:30
parent 9b89600314
commit e9e7601b3d
2 changed files with 20 additions and 2 deletions
+19 -1
View File
@@ -104,13 +104,31 @@ class ProductImagesAdmin(ModelAdmin):
search_fields = ['name']
compressed_fields = True
warn_unsaved_form = True
list_display = ['display_image', 'name',]
formfield_overrides = {
ArrayField: {
"widget": ArrayWidget,
}
}
@display(description='محصول', header=True)
def display_image(self, instance):
if instance and instance.image:
image = instance.image.url
else:
image = None
return [
instance.name,
None,
None,
{
"path": image,
"height": 30,
"width": 30,
"borderless": True,
# "squared": True,
},
]