我正在运行 Django 1.10.6、Django-cms 3.4.2、Django-blog-zinnia 0.18.1 和 cmsplugin-zinnia==0.8.1(从 github fork 下载,其中实现了 django 1.10 兼容性)
我被这个问题困扰太久了,大脑正在融化
我已经完成了手册上说的所有事情
zinnia_integration
我在我的项目中创建了一个自定义应用程序:
zinnia_integration/models.py
from django.db import models
from zinnia.models_bases.entry import AbstractEntry
class EntryWithNewUrl(AbstractEntry):
"""Entry with '/blog/<slug>/' URL"""
@models.permalink
def get_absolute_url(self):
return ('zinnia:entry_detail', (),
{'slug': self.slug})
class Meta(AbstractEntry.Meta):
abstract = True
zinnia_integration/views.py
from django.views.generic.detail import DetailView
from zinnia.models.entry import Entry
from zinnia.views.mixins.entry_preview import EntryPreviewMixin
from zinnia.views.mixins.entry_protection import EntryProtectionMixin
class EntryDetail(EntryPreviewMixin,
EntryProtectionMixin,
DetailView):
queryset = Entry.published.on_site()
template_name_field = 'template'
zinnia_integration/urls.py
from django.conf.urls import url
from zinnia_integration.views import EntryDetail
urlpatterns = [
url(r'^(?P<slug>[-\w]+)/$',
EntryDetail.as_view(),
name='entry_detail'),
]
我在我的项目的 urls.py 中包含了这个 urlpatterns
blog_urls = ([
...
url(r'^blog/comments/', include('zinnia.urls.comments')),
url(r'^blog/', include('zinnia_integration.urls')),
#url(r'^blog/', include('zinnia.urls.entries')),
url(r'^blog/', include('zinnia.urls.archives')),
....
], 'zinnia')
urlpatterns = [
...
url(r'^', include(blog_urls)),
...
]
在我的 settings.py
ZINNIA_ENTRY_BASE_MODEL = 'zinnia_integration.models.EntryWithNewUrl'
之后,我重新启动服务器并获取
NoReverseMatch at /
Reverse for 'zinnia_entry_add' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
即使我没有更改子类模型(EntryWithNewUrl)中的任何内容,我仍然会收到错误消息!