{"id":288,"date":"2008-07-03T12:54:00","date_gmt":"2008-07-03T12:54:00","guid":{"rendered":"http:\/\/new.cottee.org\/2008\/07\/newforms-admin-flatpages\/"},"modified":"2008-07-03T12:54:00","modified_gmt":"2008-07-03T12:54:00","slug":"newforms-admin-flatpages","status":"publish","type":"post","link":"https:\/\/cottee.org\/?p=288","title":{"rendered":">NewForms Admin &#8211; Flatpages"},"content":{"rendered":"<p>><a href=\"http:\/\/www.apress.com\/book\/view\/1590599969\">Practical Django Projects<\/a> (Chapter three), talks about defining an admin interface which is all well and good unless you&#8217;re using the NewForms Admin branch (which is intended to become part of Release 1.0). So if you&#8217;re an early adopter or reading this after the big change, you&#8217;ll be needing to do the following. <\/p>\n<p>The reason I bothered writing this was I couldn&#8217;t work out how to override the fact that FlatPage had already registered a ModelAdmin (try to register yours throws an error). A pointer from #django on irc and a look at the source code revealed that unregister was the baby you wanted. <\/p>\n<pre>from django.contrib import admin<br \/>from search.models import SearchKeyword<br \/>from django.contrib.flatpages.models import FlatPage<br \/><br \/>class SearchKeywordInline(admin.TabularInline):<br \/>    model = SearchKeyword<br \/>    <br \/>class FlatPageAdmin(admin.ModelAdmin):<br \/>    inlines = [<br \/>        SearchKeywordInline,<br \/>        ]<br \/><br \/># We have to unregister it, and then reregister<br \/>admin.site.unregister(FlatPage)<br \/>admin.site.register(FlatPage, FlatPageAdmin)<br \/><\/pre>\n<div class=\"blogger-post-footer\"><img width='1' height='1' src='https:\/\/blogger.googleusercontent.com\/tracker\/9210244490645736884-1563838065664443735?l=blog.cottee.org' alt='' \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>>Practical Django Projects (Chapter three), talks about defining an admin interface which is all well and good unless you&#8217;re using the NewForms Admin branch (which is intended to become part of Release 1.0). So if you&#8217;re an early adopter or reading this after the big change, you&#8217;ll be needing to do the following. The reason I bothered writing this was I couldn&#8217;t work out how to override the fact that FlatPage had already registered a ModelAdmin (try to register yours&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/cottee.org\/?p=288\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[17],"class_list":["post-288","post","type-post","status-publish","format-standard","hentry","category-oldsite","tag-django"],"_links":{"self":[{"href":"https:\/\/cottee.org\/index.php?rest_route=\/wp\/v2\/posts\/288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cottee.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cottee.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cottee.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cottee.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=288"}],"version-history":[{"count":0,"href":"https:\/\/cottee.org\/index.php?rest_route=\/wp\/v2\/posts\/288\/revisions"}],"wp:attachment":[{"href":"https:\/\/cottee.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cottee.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cottee.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}