divio/django-cms — Issue #1103: Enabling 'Edit' in Toolbar for AppHook'd app using a placeholder causes PageNotFound
Author: pastylegs
Created: 2011-11-30 11:33:35+00:00
State: open

Using cms 2.2 and django 1.3

I have an application that is connected to a django-cms page and makes use of a PlaceholderField, i.e:

/mypage/ # To a cms page
/mypage/customview/ # To a template rending the placeholder field

It works fine until I enable edit mode via the toolbar. Once I have enabled this I constantly get a

> Page matching query does not exist.

Here is the trace:

http://dpaste.com/663774/

I've looked into it and noticed that the toolbar is essentially looking to see if the viewer has permission to edit the "current page":

self.can_change = (self.request.current_page and ...) # django-cms/cms/cms_toolbar.py", line 65

The current page is retrieved from the AppResolver and belongs (I presume) to the page on which the AppHook is set. The problem seems to stem from the queryset returned from **utils.moderator. get_model_queryset()** which doesn't contain the page belonging to the apphook, hence throwing a PageDoesntExists exception

The quick fix is to set CMS_MODERATION = False in your settings but I'm not sure why this is causing a problem.

If moderation is disabled, **get_model_queryset()** returns Page.objects.drafts() which includes all pages, while Page.objects.public() only includes a subset. Why are AppHook resolved pages not in this queryset?