8000 [BUG] Placeholder rendering fails loudly without PageContent or Model · Issue #7952 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content
[BUG] Placeholder rendering fails loudly without PageContent or Model #7952
Closed
@Will-Hoey

Description

@Will-Hoey

Description

Non-root AppHook pages or Views that aren't tied to a model with placeholders will fail loudly if their parent template has any placeholders that are rendered with {% placeholder "name" %}

In CMS3 this works fine when inheriting and it just ignores the placeholders, but in CMS4 it breaks because it seemingly tries to render the placeholders. For example in our base:

{% block hero %}
    {% placeholder 'hero' %}
{% endblock hero %}
class SomeView(DetailView):
    template_name = "app/template.html"

    def get_object(self, queryset=None):
        return request.user    # Something here that doesn't define any placeholders

If we leave this block in our template.html it will attempt to render and break with NoneType should implement get_template because there's no PageContent or toolbar object.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create an app with at least 1 non-root view. Make sure there's a {{ placeholder "name" }} in the template
  2. Add the app to a page
  3. Go to the sub-page link
  4. See error

Expected behaviour

In CMS3 this simply doesn't render the placeholder. The page can load as normal with only the available placeholders

Actual behaviour

In CMS4 this fails loudly with NoneType should implement get_template

Additional information (CMS/Python/Django versions)

Only requires django-cms > 4

Linked issue

#7712

Do you want to help fix this issue?

  • Yes, I want to help fix this issue and I will join the channel #pr-reviews on the Discord Server to confirm with the community that a PR is welcome.
  • No, I only want to report the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0