Skip to content

[BUG] Changing page template fails when CMS tree is showing a different site #8276

@stefanw

Description

@stefanw

Description

When using a multi-site setup, Django CMS allows to switch the CMS page tree to other sites via the triple-dot menu. When doing this, the key cms_admin_site is set in the session. Changing the template of a page from a different site (that is open in a different tab) now gives a 404 error.

Steps to reproduce

Steps to reproduce the behavior:

  1. Open a page on Site A and go into edit mode in tab 1.
  2. Open the page tree and switch it to site B in tab 2.
  3. Change the template on the page in tab 1.
  4. See 404 error.

Expected behaviour

The template change should be saved.

Actual behaviour

A broken message modal pops up with your project's 404 page. It's confusing because the site enabled via cms_admin_site is not communicated when editing PageContent.

Additional information (CMS/Python/Django versions)

This happens in CM 5.0.1, Python 3.12, Django 5.2.

The reason is that PageContentAdmin.get_queryset automatically filters by cms_admin_site and the get_object call of the change_template view goes through get_queryset. It should probably not filter by site when directly accessing a PageContent object (site filters are likely only useful for list views in this context). This could be done by adding kwargs to get_object and get_queryset that enables/disables the site filter.

Alternatively, the session mechanism could be removed and the CMS page tree could be filtered explicitly via a site query parameter instead.

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions