From e9e7601b3d79d530d9a0ee4a24b61e6f4dfa1a60 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Mon, 20 Oct 2025 18:56:48 +0330 Subject: [PATCH] update admin and image for product image --- backend/product/admin.py | 20 +++++++++++++++++++- backend/requirements.txt | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/backend/product/admin.py b/backend/product/admin.py index 47e2a09..06800fc 100644 --- a/backend/product/admin.py +++ b/backend/product/admin.py @@ -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, + }, + ] diff --git a/backend/requirements.txt b/backend/requirements.txt index 90a4e23..70d2e54 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -40,7 +40,7 @@ django-iranian-cities==1.0.2 django-jalali==7.3.0 django-storages==1.14.5 django-timezone-field==7.1 -django-unfold==0.48.0 +django-unfold==0.65.0 djangorestframework==3.15.2 djangorestframework-simplejwt==5.3.1 djoser==2.3.1