django-cms: Placeholders not showing up in structure mode sidebar

Summary

Static placeholders and placeholders attached to a model via a PlaceholderField and rendered using render_placeholder stopped showing up in the structure mode sidebar after upgrading to v3.5. Placeholders on regular cms pages still work as expected.

This issue only manifests on url endpoints which have a page node attached, but are served by a view other than cms.views.details. After some investigation it turns out that this is because the toolbar wrongly selects the ContentRenderer instead of the LegacyRenderer in such cases. It does so on the assumption (in BaseToolbar.uses_legacy_structure_mode) that a truthy value of the request.current_page attribute signals that the current request is being serviced by the built-in cms.views.details view, which supports the non-legacy structure mode.

We managed to work around the issue by replacing the CurrentPageMiddleware with a middleware that sets request.current_page = None instead as some of the built-in cms toolbars rely on the attribute being present when they’re being populated.

Expected behaviour

Placeholders available for editing are shown in the sidebar.

Actual behaviour

The structure mode sidebar is empty even though there are placeholders in the template being rendered.

Environment

  • Python version: 3.5.6
  • Django version: 1.11.16
  • django CMS version: 3.5.3

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 7
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Adding PlaceholderAdminMixin to the ModelAdmin an re-save the dynamic object with the PlaceholderField solves the problem for me. After reading better it is all there in the docs: http://docs.django-cms.org/en/latest/how_to/placeholders.html?highlight=PlaceholderAdminMixin

Not working for me using the following versions:

Django==2.2.11
django-cms==3.7.1
Python 3.7.3

I did manage to work around this by setting the CMS_PLACEHOLDER_CONF and using a default text plugin with some dummy text. This allowed me to edit the plugin by double click-ing on it.

What is strange is that other static placeholders, from the home page do show up in the structure toolbar …

I have a similar/likely related issue on urls that have both a cms page and an application view mounted (not via apphook). This used to work fine but now seems to result in static_placeholders located in the application template not rendering in the structure sidebar. If I remove the cms page, they reappear.