Y. Postema
Y. Postema

Reputation: 3

Error NoReverseMatch

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?

Upvotes: 0

Views: 505

Answers (1)

Alasdair
Alasdair

Reputation: 308839

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' %}

Upvotes: 4

Related Questions