我无法弄清楚为什么我会返回以下错误:
NoReverseMatch at /
Reverse for '' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
以下是我的模板中的链接:
<li><a href="{% url catalog_home %} }">Home</a></li>
以下是我的主要网址:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^', include('merged.catalog.urls')),
(r'^cart/', include('merged.cart.urls')),
(r'^checkout/', include('merged.checkout.urls')),
url(r'^admin/', include(admin.site.urls)),
)
以下是子网址:
from django.conf.urls import patterns, url, include
urlpatterns = patterns('merged.catalog.views',
(r'^$','index', {'template_name': 'catalog/index.html'}, 'catalog_home'),
)
似乎一切都井然有序,但也许我错过了一些明显的东西。
答案 0 :(得分:5)
可能有所帮助的一些变化。
在你的模板中:
<li><a href="{% url 'catalog_home' %} }">Home</a></li>
在你的urls.py
中from django.conf.urls import patterns, url, include
urlpatterns = patterns('merged.catalog.views',
(r'^$','index', {'template_name': 'catalog/index.html'}, name='catalog_home'),
)