Question

J'écris une application personnalisée pour Django CMS, mais l'erreur suivante lorsque vous essayez d'afficher une entrée publiée dans l'admin:

  

TemplateSyntaxError à / admin / cmsplugin_publisher / entrée /

     

Pris NoReverseMatch tout en rendant: inverse pour 'cmsplugin_publisher_entry_detail' avec des arguments '()' et arguments mot-clé '{' Slug ': u'test-allemand'}. » Not found

Je peux obtenir l'application de travail si je donne l'application d'une URL dans mon principal urls.py d'application, mais qui fixe l'application à une URL nécessaire, je veux simplement étendre Django CMS si l'application viendra de quelle que soit la page, il est ajouté à.

models.py URL absolue Motif

    @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'),
)

vues / 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)

vues / 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

L'intégration de l'application avec Django CMS est expliqué ici: http://github.com/divio/django-cms/blob/master/cms/docs/app_integration.txt

Il semble que la question pourrait être que je ne suis pas retourner correctement le RequestContext que j'utilise un mal de vues génériques et personnalisées dans l'application.

Le fichier d'extension py App CMS:

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)

Les pointeurs ont apprécié, il s'avère être un coriace!

scroll top