这是我的应用程序树: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