1

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.

Community
  • 1
  • 1
markwalker_
  • 12,078
  • 7
  • 62
  • 99
  • Possible duplicate of [How to add some extra fields to the page in django-cms? (in django admin panel)](http://stackoverflow.com/questions/10293641/how-to-add-some-extra-fields-to-the-page-in-django-cms-in-django-admin-panel) – Flimm Aug 11 '16 at 11:21
  • @Flimm the 'answer' to that question is what I did here, resulting in an error. – markwalker_ Aug 11 '16 at 11:50
  • 1
    I know, but the question is the same, it's just that the existing answers didn't work. I've added an answer to that question now using the way @yakky recommends. – Flimm Aug 11 '16 at 12:50

1 Answers1

1

The documented API to add information and settings to page and titles is documented at http://docs.django-cms.org/en/release-3.3.x/how_to/extending_page_title.html and allows adding data to both Page (language-indipendent) and Titles (language-dependent) models. Currently there is no official way to directly extend the PageAdmin.

Flimm
  • 136,138
  • 45
  • 251
  • 267
yakky
  • 301
  • 1
  • 6