如何修改Mezzanine关键字以进行不同的验证?
admin的源代码:http://mezzanine.jupo.org/docs/_modules/mezzanine/blog/admin.html
我需要进行以下验证:
This is a tag --> thisisatag
Tag --> tag
tag --> tag
如何修改博客帖子关键字的字段集如果我取消注册博客帖子并再次注册并进行深度复制?
这是我目前的代码:
blogpost_fieldsets = deepcopy(DisplayableAdmin.fieldsets)
blogpost_fieldsets[0][1]["fields"].insert(1, "categories")
blogpost_fieldsets[0][1]["fields"].extend(["content", "allow_comments"])
blogpost_list_display = ["title", "user", "status", "admin_link"]
if settings.BLOG_USE_FEATURED_IMAGE:
blogpost_fieldsets[0][1]["fields"].insert(-2, "featured_image")
blogpost_list_display.insert(0, "admin_thumb")
blogpost_fieldsets = list(blogpost_fieldsets)
blogpost_fieldsets.insert(1, (_("Other posts"), {
"classes": ("collapse-open",),
"fields": ("related_posts",)}))
blogpost_list_filter = deepcopy(DisplayableAdmin.list_filter) + ("categories",)
@admin.register(BlogPost)
class BlogPostCustomAdmin(TweetableAdminMixin, DisplayableAdmin, OwnableAdmin):
"""
Custom admin class for blog posts.
"""
fieldsets = blogpost_fieldsets
list_display = blogpost_list_display
list_filter = blogpost_list_filter
filter_horizontal = ("categories", "related_posts",)
def save_form(self, request, form, change):
"""
Super class ordering is important here - user must get saved first.
"""
OwnableAdmin.save_form(self, request, form, change)
return DisplayableAdmin.save_form(self, request, form, change)
admin.site.unregister(BlogPost)