Reputation: 1219
I have the following URLs in my project urls.py
urlpatterns = i18n_patterns(
url(r'^register/', include('register.urls')),
)
So I maintain urls in the register app, so the urls.py
in my register
app looks like this:
urlpatterns = patterns(
url(r'^test/$', views.Test, name="register_test"),
)
So I have a template that is located outside the register app, is located in the root of the project, and I am trying to use the above url like this:
<a href="{% url 'register_test' %}"/>Test</a>
But I get the following error:
NoReverseMatch at /en/
Reverse for 'register_test' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Upvotes: 0
Views: 464
Reputation: 25549
Have you tried: <a href="{% url 'register:register_test' %}"/>Test</a>
?
You might want to give the register urls a name space first though:
urls.py
urlpatterns = i18n_patterns(
url(r'^register/', include('register.urls', namespace='register'),
)
urls.py in register app:
urlpatterns = patterns(
'register.views',
url(r'^test/$', 'Test', name="register_test"),
)
Django doc about url namespace.
Upvotes: 1
Reputation: 11695
project urls.py
urlpatterns = i18n_patterns(
url(r'^register/', include('register.urls', namespace="register")),
)
app urls.py
urlpatterns = patterns(
url(r'^test/$', views.Test, name="register_test"),
)
template.html
<a href="{% url 'register:register_test' %}"/>Test</a>
Upvotes: 0