From 5fbdf4c3e57a7e23421cf9fcd45c7d7e2d530d56 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 12 Sep 2020 16:39:07 +0200 Subject: [PATCH] Rewrite page fieldsets so they reflect article's --- articles/admin.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/articles/admin.py b/articles/admin.py index 7c36898..70e4c28 100644 --- a/articles/admin.py +++ b/articles/admin.py @@ -27,13 +27,13 @@ class ArticleAdmin(admin.ModelAdmin): ( "Metadata", { - "fields": ( + "fields": [ ("title", "slug"), ("author", "comments_allowed"), ("status", "published_at"), ("created_at", "updated_at"), "views_count", - ) + ] }, ), ("Content", {"fields": ("content",)}), @@ -95,20 +95,11 @@ class ArticleAdmin(admin.ModelAdmin): @register(Page) class PageAdmin(ArticleAdmin): list_display = ["position"] + ArticleAdmin.list_display - fieldsets = [ - ( - "Metadata", - { - "fields": ( - ("title", "slug", "position"), - ("author", "status"), - ("published_at", "created_at", "updated_at"), - "views_count", - ) - }, - ), - ("Content", {"fields": ("content",)}), - ] + + def get_fieldsets(self, request, obj=None): + article_fieldsets = ArticleAdmin.fieldsets + article_fieldsets[0][1]["fields"][0] = ("title", "slug", "position") + return article_fieldsets @register(Comment)