add image filed to product
This commit is contained in:
@@ -219,7 +219,7 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
actions_list = ['redirect_to_learn', 'update_products_price']
|
||||
list_display = ['display_image', 'display_price', 'view', 'show', 'rating', 'category', 'created_at']
|
||||
fieldsets = (
|
||||
('فیلد های اصلی', {'fields': ('name', 'description', 'category', 'related_products', 'show', 'shop', 'show_in_bot', 'bot_banner'), "classes": ["tab"],}),
|
||||
('فیلد های اصلی', {'fields': ('name', 'description', 'category', 'image', 'related_products', 'show', 'shop', 'show_in_bot', 'bot_banner'), "classes": ["tab"],}),
|
||||
('فیلد های سيو', {'fields': ('meta_description', 'meta_keywords', 'meta_rating', 'slug'), "classes": ["tab"],}),
|
||||
('فیلد های مربوط به کاربر', {'fields': ('rating', 'view',), "classes": ["tab"],}),
|
||||
# ('فیلد های ایتم های پک', {'fields': ('in_pack_items', ), "classes": ["tab"],})
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.1.2 on 2025-10-29 16:59
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0055_alter_productmodel_options'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='productmodel',
|
||||
name='image',
|
||||
field=models.ImageField(default='', upload_to='product_main/'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
@@ -111,6 +111,7 @@ class InPackItems(models.Model):
|
||||
class ProductModel(models.Model):
|
||||
name = models.CharField(max_length=255, verbose_name='نام')
|
||||
description = models.TextField(verbose_name='توضیحات')
|
||||
image = models.ImageField(upload_to='product_main/')
|
||||
rating = models.PositiveIntegerField(default=0, verbose_name='امتیاز')
|
||||
show = models.BooleanField(default=False, verbose_name='نمایش در خانه')
|
||||
view = models.IntegerField(default=0, verbose_name='بازدید')
|
||||
|
||||
@@ -130,10 +130,10 @@ class DynamicProductSerializer(serializers.ModelSerializer):
|
||||
model = ProductModel
|
||||
fields = "__all__"
|
||||
view_type = {
|
||||
'list': ['id','name', 'rating', 'slug', 'category', 'variants', 'colors'],
|
||||
'slider': ['id','name', 'rating', 'slug', 'category', 'variants', 'colors'],
|
||||
'instance': ['id', 'name', 'description', 'rating', 'slug', 'meta_description', 'meta_keywords', 'meta_rating', 'category', 'related_products', 'in_pack_items', 'variants', 'colors', 'added_to_favorites'],
|
||||
'chat': ['id', 'name', 'description', 'variants']
|
||||
'list': ['id','name', 'rating', 'slug', 'category', 'variants', 'colors', 'image'],
|
||||
'slider': ['id','name', 'rating', 'slug', 'category', 'variants', 'colors', 'image'],
|
||||
'instance': ['id', 'name', 'description', 'rating', 'slug', 'meta_description', 'meta_keywords', 'meta_rating', 'category', 'related_products', 'in_pack_items', 'variants', 'colors', 'added_to_favorites', 'image'],
|
||||
'chat': ['id', 'name', 'description', 'variants', 'image']
|
||||
}
|
||||
|
||||
def get_added_to_favorites(self, obj):
|
||||
|
||||
Reference in New Issue
Block a user