I appear to have an issue with permissions when extending the PageAdmin
class with inlines.
From my debugging it seems that I don't have permission to add admin inlines as the following method from PageAdmin
is returning an empty list.
def get_inline_classes(self, request, obj=None, **kwargs):
if obj and 'permission' in request.path:
return PERMISSION_ADMIN_INLINES
return []
I'm a site superuser so how do you get permission to do this? CMS_PERMISSION = True
is in settings (although I'll admit I've never looked in to what this does).
I've not tried to extend the PageAdmin before but need to extend the Page options so I've written the following model;
class ShowPageChildren(models.Model):
page = models.ForeignKey(
Page,
unique=True,
verbose_name=_("Page"),
editable=False,
related_name='child_menu'
)
show_children = models.BooleanField(
default=False
)
text = models.CharField(
max_length=255,
help_text=_("To accompany the page title in the menu")
)
When I load up the basic settings for a Page there are no inlines, but mine is being loaded with the following admin.py
;
class ShowPageChildrenAdmin(admin.StackedInline):
print '\n\nShowPageChildrenAdmin\n\n'
model = ShowPageChildren
can_delete = False
PageAdmin.inlines.append(ShowPageChildrenAdmin)
try:
admin.site.unregister(Page)
except:
pass
admin.site.register(Page, PageAdmin)
Is this the correct way to add to the CMS PageAdmin settings?
Edit following answer from yakky
I attempted this implementation following an old answer on here which made it look like it would work, in theory. So I just implemented the usual Page extension & added a separate menu item to the Page menu. I have also added to the settings extension discussion on the project with regard to implementing this functionality.