I'm writing a custom app for Django CMS, but get the following error when trying to view a published entry in the admin:
TemplateSyntaxError at /admin/cmsplugin_publisher/entry/
Caught NoReverseMatch while rendering: Reverse for 'cmsplugin_publisher_entry_detail' with arguments '()' and keyword arguments '{'slug': u'test-german'}' not found.
I can get the app working if I give the app a URL in my main application urls.py, but that fixes the app to a required URL, I just want extend Django CMS so the app will come from whichever page it's added to.
models.py Absolute URL Pattern
@models.permalink
def get_absolute_url(self):
return ('cmsplugin_publisher_entry_detail', (), {
'slug': self.slug})
urls/entries.py
from django.conf.urls.defaults import *
from cmsplugin_publisher.models import Entry
from cmsplugin_publisher.settings import PAGINATION, ALLOW_EMPTY, ALLOW_FUTURE
entry_conf_list = {'queryset': Entry.published.all(), 'paginate_by': PAGINATION,}
entry_conf = {'queryset': Entry.published.all(),
'date_field': 'creation_date',
'allow_empty': ALLOW_EMPTY,
'allow_future': ALLOW_FUTURE,
}
entry_conf_detail = entry_conf.copy()
del entry_conf_detail['allow_empty']
del entry_conf_detail['allow_future']
del entry_conf_detail['date_field']
entry_conf_detail['queryset'] = Entry.objects.all()
urlpatterns = patterns('cmsplugin_publisher.views.entries',
url(r'^$', 'entry_index', entry_conf_list,
name='cmsplugin_publisher_entry_archive_index'),
url(r'^(?P<page>[0-9]+)/$', 'entry_index', entry_conf_list,
name='cmsplugin_publisher_entry_archive_index_paginated'),
)
urlpatterns += patterns('django.views.generic.list_detail',
url(r'^(?P<slug>[-\w]+)/$', 'object_detail', entry_conf_detail,
name='cmsplugin_publisher_entry_detail'),
)
views/entries.py
from django.views.generic.list_detail import object_list
from cmsplugin_publisher.models import Entry
from cmsplugin_publisher.views.decorators import update_queryset
entry_index = update_queryset(object_list, Entry.published.all)
views/decorators.py
def update_queryset(view, queryset, queryset_parameter='queryset'):
'''Decorator around views based on a queryset passed in parameter which will force the update despite cache
Related to issue http://code.djangoproject.com/ticket/8378'''
def wrap(*args, **kwargs):
'''Regenerate the queryset before passing it to the view.'''
kwargs[queryset_parameter] = queryset()
return view(*args, **kwargs)
return wrap
The app integration with Django CMS is explained here: http://github.com/divio/django-cms/blob/master/cms/docs/app_integration.txt
It looks like the issue might be that I'm not correctly returning the RequestContext as I'm using a mis of generic views and custom in the application.
The CMS App extension py file:
cms_app.py
from django.utils.translation import ugettext_lazy as _
from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
from cmsplugin_publisher.settings import APP_MENUS
class PublisherApp(CMSApp):
name = _('Publisher App Hook')
urls = ['cmsplugin_publisher.urls']
apphook_pool.register(PublisherApp)
Any pointers appreciated, it's proving to be a tough nut to crack!