Reputation: 1386
This is my application tree :
myapp/
assets/
statics/
settings.py
urls.py
\\other stuff
main/
urls.py
views.py
templates/
base.html
index.html
\\other stuff
manage.py
When testing my application, I have the following error :
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.
Here is the code in base.html
involved in the error :
{% load i18n %}
\\some stuff
<a class="brand" href="{% url 'index' %}">{{ site.name }}</a> <--- this line is the error
in main/urls.py
I have :
urlpatterns = patterns('',
(r'^$', TemplateView.as_view(template_name="index.html")),
)
in myapp/urls.py
I have :
urlpatterns = patterns('',
url(r'', include('main.urls'), name='index'),
)
Can someone please tell my what I am doing wrong and why the name 'index'
is not reverse matched?
Upvotes: 0
Views: 681
Reputation: 6255
name
is for single views, it doesn't go with the include statement. Try this way:
in main/urls.py:
urlpatterns = patterns('',
url(r'^$', TemplateView.as_view(template_name="index.html"),
name='index'),
)
in myapp/urls.py:
urlpatterns = patterns('',
url(r'', include('main.urls')),
)
Upvotes: 3