0

我遵循本教程:https ://github.com/chronossc/django-breadcrumbs/blob/master/README.markdown#3---enable-flatpages--breadcrumbs

像这样,我的settings.py:

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'breadcrumbs.middleware.BreadcrumbsMiddleware',
    'breadcrumbs.middleware.FlatpageFallbackMiddleware',
)

INSTALLED_APPS = (
    ...
    'django.contrib.flatpages',
    ...
    'breadcrumbs',
)

和我的 urls.py:

from django.conf.urls import patterns, include, url
from django.conf import settings
from django.conf.urls.static import static

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    ...
    url(r'^services/(?P<url>.*)$', 'breadcrumbs.views.flatpage'),
    ...

)

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

if settings.DEBUG:
    urlpatterns += patterns('django.contrib.staticfiles.views',
        url(r'^static/(?P<path>.*)$', 'serve'),
    )

所以,

如果我删除了我的中间件类,那么平面页面就不起作用了。但是,如果我删除我的服务 url,平面页面会再次工作。他不使用这个。我需要知道使系统正常工作的原因。

再次感谢!

4

1 回答 1

0

似乎由于某种原因找不到“breadcrumbs.views.flatpage”。让我们明确地导入它。

from django.conf.urls import patterns, include, url
from django.conf import settings
from django.conf.urls.static import static

from breadcrumbs.views import flatpage

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    ...
    url(r'^services/(?P<url>.*)$', flatpage),
    ...

)
于 2013-10-30T12:43:03.523 回答