Having problems with getting login to work even though it's well
documented. The pages for success, invalid, and no info provided
aren't getting used at all. Instead, clicking login always redirects
to /login which is not what I want. Any ideas?

URLconf:
...
(r'^accounts/login/$', 'django.contrib.auth.views.login'),

View:
...
def login(request):
    username = request.POST['username']
    password = request.POST['password']
    user = authenticate(username=username, password=password)
    if user is not None:
        if user.is_active:
            login(request, user)
            return HttpResponseRedirect('/registration/
login_success/')
        else:
            return HttpResponseRedirect('/registration/
login_incorrect/')
    else:
        return HttpResponseRedirect('/registration/no_info/')

HTML template:

{% extends "base.html" %}
{% load url from future %}

{% block title %}
Login Page
{% endblock %}

{% block style %}
body{
background-color:pink;
}
{% endblock %}


{% block content %}

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

<h1>Login</h1>
<form method="post" action="/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 %}

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

Reply via email to