0

I keep running in to a NoReverseMatch error on Django 1.10, while earlier versions have no problems with it.

rendered template:

{% extends "loginBase.html" %}

{% block content %}

<h1>Login:</h1>
  <form class="form-horizontal" role="form" method="post" action="{% url     'django.contrib.auth.views.login' %}">
{% csrf_token %}
  {% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
    {% endif %}

urls.py

url(r'^login/$', views.login, {'template_name': 'login.html', 'authentication_form': LoginForm}, name='login'),

Any ideas on what the problem might be?

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • 2
    Possible duplicate of [What is a NoReverseMatch error, and how do I fix it?](http://stackoverflow.com/questions/38390177/what-is-a-noreversematch-error-and-how-do-i-fix-it) – Sayse Aug 08 '16 at 12:26
  • 1
    Use just `{% url 'login' %}` – Anna Aug 08 '16 at 12:32
  • Possible duplicate of [NoReverseMatch Error](http://stackoverflow.com/questions/4981026/noreversematch-error) – be_good_do_good Aug 08 '16 at 12:39
  • @be_good_do_good - the answer you've linked to is Django < 1.5, so it's *really* out of date. – Alasdair Aug 08 '16 at 13:12

1 Answers1

4

In Django 1.10, you can no longer reverse URLs using the Python dotted path, e.g. 'django.contrib.auth.views.login'.

You already have name='login' in your URL pattern,

url(r'^login/$', views.login, {...}, name='login'),

so use that in the url tag:

{% url 'login' %}
Alasdair
  • 298,606
  • 55
  • 578
  • 516