2013-10-30 94 views
0

我跟隨此教程:https://github.com/chronossc/django-breadcrumbs/blob/master/README.markdown#3---enable-flatpages--breadcrumbsDjango的麪包屑的flatpages

這樣,我的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'), 
    ) 

所以,

如果我刪除我的中間件類,那麼這些頁面不起作用。但是,如果我刪除了我的服務網址,那麼平板電腦會再次運行。他不使用這個。我需要知道做出正確系統工作的原因。

再次感謝!

回答

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), 
    ... 

)