No Reverse Match with Django Auth Views
<p>I created a custom User model following the example in the Django documentation, now I'm trying to use Django auth views but I keep getting <code>NoReverseMatch at /accounts/login/</code></p>

<pre><code>Reverse for 'django.contrib.auth.views.login' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
</code></pre>

<p>This is the url conf:</p>

<pre><code>from django.contrib.auth import views as auth_views

urlpatterns = [
    url(r'^accounts/login/$', auth_views.login, {'template_name': 'login.html',
        'authentication_form': LoginForm}),
    url(r'^logout/$', auth_views.logout, {'next_page': '/accounts/login'}),
    url(r'^$', home, name="home"),    
    ]
</code></pre>

<p>And I have this line in my template:</p>

<pre><code>&lt;form method="post" action="{% url 'django.contrib.auth.views.login' %}"&gt;
</code></pre>

<pre><code>{% url 'django.contrib.auth.views.login' %}
</code></pre>

<p>This is incorrect. We put the name given to the url here instead of the location of the view.</p>

<p>Please see <a href="https://docs.djangoproject.com/en/1.10/ref/templates/builtins/#url" rel="nofollow">https://docs.djangoproject.com/en/1.10/ref/templates/builtins/#url</a>. You need to provide a name for login like you have for home and then use that.</p>

<p>Correct way is:
urls.py -></p>

<pre><code>url(r'^accounts/login/$', auth_views.login, {'template_name': 'login.html','authentication_form': LoginForm}, name="login") ,
</code></pre>

<p>template -></p>

<pre><code>&lt;form method="post" action="{% url 'login' %}"&gt;
</code></pre>

python django