Wednesday, March 28, 2012

django.contrib.auth.views.login no response

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/g3sCK82eI0gJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment