A NoReverseMatch
error is a consequence of Django not being able to find a URL in its mapping system that resolves to a particular view, either in the template ( url
tag) or in the Python code ( reverse
). In your case, the error is given when trying to form a URL for login.views.registrar
, so you need to see if there is any pattern in the urls.py
that maps to that view .
In your complete example (in original revision of the question) I see that there is nothing in the urls.py
main (the project) that routes to any view of login
:
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'', include('article.urls'))
]
As you already have a urls.py
in the app login
, with a mapping for the view :
urlpatterns = [
url(r'^registrar/new/$', views.registrar, name='registrar'),
]
So all you have to do is add a route to the login
app, just like you did for article
. The type of URL you choose, but as an example, assuming your site is in http://example.com/django/
and you set your urlpatterns
like this:
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'', include('article.urls'))
url(r'login/', include('login.urls'))
]
Then the {% url "login.views.registrar" %}
tag will be replaced by:
http://example.com/django/login/registrar/new/
And this URL will serve the result of view login.views.registrar
. Feel free to choose another routing, if you wish, the important thing is that some routing for the view exists to avoid NoReverseMatch
.