Sample login template doesn't work as it is #37

Closed
edhedges opened this Issue Jun 14, 2012 · 1 comment

2 participants

@edhedges

This should be a quick fix and if no one does it before I can I will put in a pull request but at this link: https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.views.login where it shows the example login template there is a tiny error.

Here is what is presently there:

{% extends "base.html" %}

{% block content %}

{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}

<form method="post" action="{% url 'django.contrib.auth.views.login' %}">
{% csrf_token %}
<table>
<tr>
    <td>{{ form.username.label_tag }}</td>
    <td>{{ form.username }}</td>
</tr>
<tr>
    <td>{{ form.password.label_tag }}</td>
    <td>{{ form.password }}</td>
</tr>
</table>

<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />
</form>

{% endblock %}

The line that is breaks at is <form method="post" action="{% url 'django.contrib.auth.views.login' %}"> and it is because there shouldn't be any single quotes around django.contrib.auth.views.login.

Here is the correct version:

{% extends "base.html" %}

{% block content %}

{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}

<form method="post" action="{% url django.contrib.auth.views.login %}">
{% csrf_token %}
<table>
<tr>
    <td>{{ form.username.label_tag }}</td>
    <td>{{ form.username }}</td>
</tr>
<tr>
    <td>{{ form.password.label_tag }}</td>
    <td>{{ form.password }}</td>
</tr>
</table>

<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />
</form>

{% endblock %}
@aaugustin
Django member

This isn't a bug of the djangoproject.com website, and it isn't a bug at all.

The syntax of the {% url %} tag changed in Django 1.5.

@aaugustin aaugustin closed this Feb 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment