detail product and in pack items for product
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from .models import *
|
||||
from unfold.admin import ModelAdmin, TabularInline
|
||||
from unfold.admin import ModelAdmin, TabularInline, StackedInline
|
||||
|
||||
from import_export.admin import ImportExportModelAdmin
|
||||
from unfold.contrib.import_export.forms import ExportForm, ImportForm, SelectableFieldsExportForm
|
||||
@@ -10,6 +10,20 @@ from unfold.widgets import (
|
||||
UnfoldAdminColorInputWidget,
|
||||
)
|
||||
from unfold.decorators import action, display
|
||||
|
||||
@admin.register(InPackItems)
|
||||
class InPackItemsAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
import_form_class = ImportForm
|
||||
export_form_class = ExportForm
|
||||
search_fields = ['item_title']
|
||||
compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
|
||||
formfield_overrides = {
|
||||
ArrayField: {
|
||||
"widget": ArrayWidget,
|
||||
}
|
||||
}
|
||||
class InStuckColorsInLine(TabularInline):
|
||||
model = InStuckColors
|
||||
extra = 0
|
||||
@@ -17,23 +31,52 @@ class InStuckColorsInLine(TabularInline):
|
||||
formfield_overrides = {
|
||||
models.CharField: {"widget": UnfoldAdminColorInputWidget()},
|
||||
}
|
||||
verbose_name = 'رنگ موجود'
|
||||
verbose_name_plural = 'رنگهای موجود'
|
||||
|
||||
|
||||
@admin.register(DetailModel)
|
||||
class DetailModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
import_form_class = ImportForm
|
||||
export_form_class = ExportForm
|
||||
search_fields = ['title']
|
||||
compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
|
||||
formfield_overrides = {
|
||||
ArrayField: {
|
||||
"widget": ArrayWidget,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class DetailModelInLine(StackedInline):
|
||||
model = ProductDetailModel
|
||||
extra = 0
|
||||
tab = True
|
||||
autocomplete_fields = ['detail']
|
||||
verbose_name = 'جزئیات محصول'
|
||||
verbose_name_plural = 'جزئیات محصول'
|
||||
|
||||
@admin.register(ProductModel)
|
||||
class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
import_form_class = ImportForm
|
||||
export_form_class = ExportForm
|
||||
inlines = [InStuckColorsInLine]
|
||||
inlines = [InStuckColorsInLine, DetailModelInLine]
|
||||
readonly_fields = ('slug', )
|
||||
search_fields = ['name', 'description', ]
|
||||
list_filter = ['currency', 'show', 'category']
|
||||
autocomplete_fields = ['related_products']
|
||||
autocomplete_fields = ['related_products', 'in_pack_items']
|
||||
# compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
list_display = ['display_image', 'display_price', 'view', 'show', 'rating', 'category', 'discount', 'sell']
|
||||
fieldsets = (
|
||||
('Main Fileds', {'fields': ('name', 'description', 'price', 'min_price', 'currency', 'discount', 'category', 'related_products', 'show',), "classes": ["tab"],}),
|
||||
('SEO Fileds', {'fields': ('meta_description', 'meta_keywords', 'meta_rating', 'slug'), "classes": ["tab"],}),
|
||||
('Users Fileds', {'fields': ('rating', 'view', 'sell', ), "classes": ["tab"],})
|
||||
('فیلد های اصلی', {'fields': ('name', 'description', 'price', 'min_price', 'currency', 'discount', 'category', 'related_products', 'show',), "classes": ["tab"],}),
|
||||
('فیلد های سيو', {'fields': ('meta_description', 'meta_keywords', 'meta_rating', 'slug'), "classes": ["tab"],}),
|
||||
('فیلد های مربوط به کاربر', {'fields': ('rating', 'view', 'sell', ), "classes": ["tab"],}),
|
||||
('فیلد های ایتم های پک', {'fields': ('in_pack_items', ), "classes": ["tab"],})
|
||||
|
||||
)
|
||||
formfield_overrides = {
|
||||
|
||||
Reference in New Issue
Block a user