new sliders add for home page
This commit is contained in:
@@ -295,16 +295,16 @@ class ProductModelAdmin(ProductAdminPermission, ModelAdmin, ImportExportModelAdm
|
||||
inlines = [ProductVariantInLine]
|
||||
readonly_fields = ('slug', 'created_at')
|
||||
search_fields = ['name', 'description', ]
|
||||
list_filter = ['show', ('category', RelatedDropdownFilter), 'show_in_bot', ('category__parent', RelatedDropdownFilter)]
|
||||
list_filter = [('category', RelatedDropdownFilter), 'show_in_bot', ('category__parent', RelatedDropdownFilter)]
|
||||
list_filter_submit = True
|
||||
autocomplete_fields = ['related_products', 'shop', 'category']
|
||||
# compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
# list_per_page = 2
|
||||
actions_list = ['redirect_to_learn', 'update_products_price']
|
||||
list_display = ['display_image', 'shop__shop_name','display_price', 'view', 'show', 'rating', 'category', 'created_at']
|
||||
list_display = ['display_image', 'shop__shop_name','display_price', 'view', 'rating', 'category', 'created_at']
|
||||
fieldsets = (
|
||||
('فیلد های اصلی', {'fields': ('name', 'description', 'category', 'image', 'related_products', 'show', 'shop', 'show_in_bot', 'bot_banner'), "classes": ["tab"],}),
|
||||
('فیلد های اصلی', {'fields': ('name', 'description', 'category', 'image', 'related_products','show_in_trends', 'show_in_most_viewed', 'show_in_lot_of_discount', 'show_in_top_seller', '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"],})
|
||||
@@ -324,7 +324,7 @@ class ProductModelAdmin(ProductAdminPermission, ModelAdmin, ImportExportModelAdm
|
||||
if request.user.is_superuser:
|
||||
return ['slug', 'created_at']
|
||||
else:
|
||||
return ['show_in_bot', 'bot_banner', 'created_at', 'show', 'meta_description', 'meta_keywords', 'meta_rating', 'rating', 'view', 'slug']
|
||||
return ['show_in_bot', 'bot_banner', 'created_at', 'show_in_top_seller','show_in_trends', 'show_in_most_viewed', 'show_in_lot_of_discount','meta_description', 'meta_keywords', 'meta_rating', 'rating', 'view', 'slug']
|
||||
|
||||
def display_price(self, obj):
|
||||
if obj.variants.all().first():
|
||||
@@ -398,15 +398,6 @@ class ProductModelAdmin(ProductAdminPermission, ModelAdmin, ImportExportModelAdm
|
||||
actions = ['bulk_update_subcategory_action']
|
||||
|
||||
|
||||
# @display(
|
||||
# description=("نمایش در صفحه ی اصلی"),
|
||||
# label={
|
||||
# True: "danger",
|
||||
# False: "success",
|
||||
# },
|
||||
# )
|
||||
# def display_show(self, instance):
|
||||
# return instance.show
|
||||
|
||||
|
||||
@admin.register(MainCategoryModel)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# Generated by Django 5.1.2 on 2026-02-20 15:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('account', '0034_add_telegram_chat_id_to_shop'),
|
||||
('product', '0071_maincategorymodel_show_in_home'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveIndex(
|
||||
model_name='productmodel',
|
||||
name='product_show_idx',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='productmodel',
|
||||
name='show',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='productmodel',
|
||||
name='show_in_lot_of_discount',
|
||||
field=models.BooleanField(default=False, verbose_name='نمایش در پر تخفیف ها'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='productmodel',
|
||||
name='show_in_most_viewed',
|
||||
field=models.BooleanField(default=False, verbose_name='نمایش در پر بازدید ها'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='productmodel',
|
||||
name='show_in_top_seller',
|
||||
field=models.BooleanField(default=False, verbose_name='نمایش در پر فروش ها'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='productmodel',
|
||||
name='show_in_trends',
|
||||
field=models.BooleanField(default=False, verbose_name='نمایش در ترند ها'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='productmodel',
|
||||
index=models.Index(fields=['show_in_trends'], name='product_show_in_trends_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='productmodel',
|
||||
index=models.Index(fields=['show_in_most_viewed'], name='product_most_viewed_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='productmodel',
|
||||
index=models.Index(fields=['show_in_lot_of_discount'], name='product_lot_of_discount_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='productmodel',
|
||||
index=models.Index(fields=['show_in_top_seller'], name='product_show_in_top_seller_idx'),
|
||||
),
|
||||
]
|
||||
@@ -181,7 +181,10 @@ class ProductModel(models.Model):
|
||||
description = models.TextField(verbose_name='توضیحات')
|
||||
image = models.ImageField(upload_to='product_main/', null=True, blank=True)
|
||||
rating = models.PositiveIntegerField(default=0, verbose_name='امتیاز')
|
||||
show = models.BooleanField(default=False, verbose_name='نمایش در خانه')
|
||||
show_in_trends = models.BooleanField(default=False, verbose_name='نمایش در ترند ها')
|
||||
show_in_most_viewed = models.BooleanField(default=False, verbose_name='نمایش در پر بازدید ها')
|
||||
show_in_lot_of_discount = models.BooleanField(default=False, verbose_name='نمایش در پر تخفیف ها')
|
||||
show_in_top_seller = models.BooleanField(default=False, verbose_name='نمایش در پر فروش ها')
|
||||
view = models.IntegerField(default=0, verbose_name='بازدید')
|
||||
slug = models.SlugField(max_length=255, unique=True, blank=True, null=True, allow_unicode=True,
|
||||
verbose_name='نام یکتا', help_text="این فیلد را خالی بگذارید")
|
||||
@@ -224,7 +227,10 @@ class ProductModel(models.Model):
|
||||
models.Index(fields=['category'], name='product_category_idx'),
|
||||
models.Index(fields=['name'], name='product_name_idx'),
|
||||
models.Index(fields=['created_at'], name='product_created_at_idx'),
|
||||
models.Index(fields=['show'], name='product_show_idx'),
|
||||
models.Index(fields=['show_in_trends'], name='product_show_in_trends_idx'),
|
||||
models.Index(fields=['show_in_most_viewed'], name='product_most_viewed_idx'),
|
||||
models.Index(fields=['show_in_lot_of_discount'], name='product_lot_of_discount_idx'),
|
||||
models.Index(fields=['show_in_top_seller'], name='product_show_in_top_seller_idx'),
|
||||
models.Index(fields=['category', 'created_at'],
|
||||
name='product_category_created_idx'),
|
||||
models.Index(fields=['category', 'name'],
|
||||
|
||||
Reference in New Issue
Block a user