42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from django.contrib import admin
|
|
from .models import SolutionCategory, Solution
|
|
|
|
|
|
@admin.register(SolutionCategory)
|
|
class SolutionCategoryAdmin(admin.ModelAdmin):
|
|
list_display = ('name_zh', 'name_en', 'slug', 'sort_order', 'is_active')
|
|
list_filter = ('is_active',)
|
|
list_editable = ('sort_order', 'is_active')
|
|
search_fields = ('name_zh', 'name_en', 'slug')
|
|
prepopulated_fields = {'slug': ('name_en',)}
|
|
|
|
|
|
@admin.register(Solution)
|
|
class SolutionAdmin(admin.ModelAdmin):
|
|
list_display = ('title_zh', 'category', 'sort_order', 'is_active')
|
|
list_filter = ('category', 'is_active')
|
|
list_editable = ('sort_order', 'is_active')
|
|
search_fields = ('title_zh', 'title_en', 'slug')
|
|
prepopulated_fields = {'slug': ('title_en',)}
|
|
fieldsets = (
|
|
('基本信息', {
|
|
'fields': ('category', 'title_zh', 'title_en', 'slug', 'cover_image')
|
|
}),
|
|
('内容', {
|
|
'fields': ('summary_zh', 'summary_en', 'content_zh', 'content_en')
|
|
}),
|
|
('视频', {
|
|
'fields': ('video_url', 'video_file'),
|
|
'classes': ('collapse',)
|
|
}),
|
|
('SEO', {
|
|
'fields': ('seo_title_zh', 'seo_title_en',
|
|
'seo_keywords_zh', 'seo_keywords_en',
|
|
'seo_description_zh', 'seo_description_en'),
|
|
'classes': ('collapse',)
|
|
}),
|
|
('状态', {
|
|
'fields': ('sort_order', 'is_active')
|
|
}),
|
|
)
|