Add ShopModel and integrate with ProductModel
- Created ShopModel with fields for shop name, description, and user association. - Updated ProductModel to include a foreign key relationship with ShopModel. - Added admin interface for ShopModel with search functionality. - Created migrations for ShopModel and its integration with ProductModel.
This commit is contained in:
@@ -41,6 +41,18 @@ class InPackItemsAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
"widget": ArrayWidget,
|
||||
}
|
||||
}
|
||||
from account.models import ShopModel
|
||||
@admin.register(ShopModel)
|
||||
class ShopModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
search_fields = ['name']
|
||||
compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
|
||||
formfield_overrides = {
|
||||
ArrayField: {
|
||||
"widget": ArrayWidget,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class AttributeValueInLine(StackedInline):
|
||||
@@ -180,13 +192,13 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
readonly_fields = ('slug', 'created_at')
|
||||
search_fields = ['name', 'description', ]
|
||||
list_filter = ['show', 'category']
|
||||
autocomplete_fields = ['related_products', ]
|
||||
autocomplete_fields = ['related_products', 'shop']
|
||||
# compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
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',), "classes": ["tab"],}),
|
||||
('فیلد های اصلی', {'fields': ('name', 'description', 'category', 'related_products', 'show', 'shop'), "classes": ["tab"],}),
|
||||
('فیلد های سيو', {'fields': ('meta_description', 'meta_keywords', 'meta_rating', 'slug'), "classes": ["tab"],}),
|
||||
('فیلد های مربوط به کاربر', {'fields': ('rating', 'view',), "classes": ["tab"],}),
|
||||
# ('فیلد های ایتم های پک', {'fields': ('in_pack_items', ), "classes": ["tab"],})
|
||||
|
||||
Reference in New Issue
Block a user