You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.5 KiB
44 lines
1.5 KiB
from django.contrib import admin
|
|
from .models import Category, PrimaryTag, SecondaryTag, Post, Comment
|
|
|
|
@admin.register(Category)
|
|
class CategoryAdmin(admin.ModelAdmin):
|
|
list_display = ['name', 'icon', 'order', 'description']
|
|
list_editable = ['order', 'icon']
|
|
search_fields = ['name']
|
|
|
|
@admin.register(PrimaryTag)
|
|
class PrimaryTagAdmin(admin.ModelAdmin):
|
|
list_display = ['name', 'color']
|
|
search_fields = ['name']
|
|
|
|
@admin.register(SecondaryTag)
|
|
class SecondaryTagAdmin(admin.ModelAdmin):
|
|
list_display = ['name', 'tag_type', 'parent_tag']
|
|
list_filter = ['tag_type', 'parent_tag']
|
|
search_fields = ['name']
|
|
|
|
@admin.register(Post)
|
|
class PostAdmin(admin.ModelAdmin):
|
|
list_display = ['title', 'category', 'author', 'status', 'views', 'created_time']
|
|
list_filter = ['category', 'status', 'created_time']
|
|
search_fields = ['title', 'content']
|
|
filter_horizontal = ['primary_tags', 'secondary_tags']
|
|
readonly_fields = ['views', 'created_time', 'updated_time']
|
|
fieldsets = (
|
|
('基本信息', {
|
|
'fields': ('title', 'content', 'excerpt', 'author', 'category', 'featured_image')
|
|
}),
|
|
('标签管理', {
|
|
'fields': ('primary_tags', 'secondary_tags')
|
|
}),
|
|
('状态信息', {
|
|
'fields': ('status', 'views', 'created_time', 'updated_time')
|
|
}),
|
|
)
|
|
|
|
@admin.register(Comment)
|
|
class CommentAdmin(admin.ModelAdmin):
|
|
list_display = ['author', 'post', 'created_time']
|
|
list_filter = ['created_time']
|
|
search_fields = ['author', 'content'] |