django.contrib.auth.views.login no response

128 views
Skip to first unread message

jondbaker

unread,
Mar 28, 2012, 1:07:03 PM3/28/12
to django...@googlegroups.com
I'm trying to build a login form by following the instructions on this page https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.views.login. The form is rendered in the template with a username and password field, but the hidden "next" field has no value, the form does not return error messages and there's no response on submit. Here is my code:

urls.py
urlpatterns = patterns('',
    url(r'^accounts/login/$', 'django.contrib.auth.views.login', {
        'template_name': 'accounts/login.html'
    }
)

templates/accounts/login.html
{% extends 'base.html' %}
{% load url from future %}

{% 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 %}
    <div class="form-item">
    {{ form.username.label_tag }}
    {{ form.username }}
    </div>
    <div class="form-item">
    {{ form.password.label_tag }}
    {{ form.password }}
    </div>
    <input type="submit" value="login" />
    <input type="hidden" name="next" value="{{ next|escape }}" />
</form>

{% endblock %}

jondbaker

unread,
Mar 28, 2012, 4:30:24 PM3/28/12
to django...@googlegroups.com
Problem solved. It turns out that I was missing a '>' around a closing <div> tag in my base.html template, and it was the culprit.
Reply all
Reply to author
Forward
0 new messages