這是我的應用程序樹:Django的URL反向匹配誤差
myapp/
assets/
statics/
settings.py
urls.py
\\other stuff
main/
urls.py
views.py
templates/
base.html
index.html
\\other stuff
manage.py
在測試我的應用程序,我有以下錯誤:
Error during template rendering
In template /app/main/templates/base.html, error at line 32
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.
這裏是涉及錯誤base.html
的代碼:
{% load i18n %}
\\some stuff
<a class="brand" href="{% url 'index' %}">{{ site.name }}</a> <--- this line is the error
在
main/urls.py
我:
urlpatterns = patterns('',
(r'^$', TemplateView.as_view(template_name="index.html")),
)
在
myapp/urls.py
我:
urlpatterns = patterns('',
url(r'', include('main.urls'), name='index'),
)
有人可以告訴我什麼,我做錯了,爲什麼叫'index'
無反匹配?
我真的不知道該怎麼做,我想提出
在主/ urls.py「main」文件夾中的所有主頁邏輯以及「myapp」文件夾內的所有應用程序配置。 – Pol0nium 2013-05-01 16:41:13
我以前的評論很愚蠢,請查看答案。 – Alexandre 2013-05-01 16:42:53