我正在写的Django CMS的自定义应用程序,但在尝试查看管理员发布的条目时出现以下错误:Django的CMS 2.1.0应用扩展NoReverseMatch TemplateSyntaxError
TemplateSyntaxError在/管理/ cmsplugin_publisher/entry/
渲染时捕获NoReverseMatch:未找到参数'()'和关键字参数'{'slug':u'test-german'}'的'cmsplugin_publisher_entry_detail'。
我可以获取应用程序的工作,如果我给应用程序在我的主要应用urls.py一个网址,但修复了应用所需的URL,我只是想延长Django的CMS,因此该应用会从哪个它被添加到的页面。
models.py绝对URL模式
@models.permalink
def get_absolute_url(self):
return ('cmsplugin_publisher_entry_detail',(), {
'slug': self.slug})
网址/ 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'),
)
视图/ 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)
组的意见/ 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
和Django CMS的应用程序集成了说明:http://github.com/divio/django-cms/blob/master/cms/docs/app_integration.txt
它看起来像这个问题可能是我没有正确地返回的RequestContext为我在应用程序中使用错误的通用视图和自定义。
的CMS应用扩展PY文件:
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)
赞赏任何指针,它证明是一个难啃的骨头!
这是完美的固定。谢谢杰森! – Chris 2010-08-12 14:36:22