My view function uses the login required decorator:

@login_required(redirect_field_name='next')
def index(request):
   lists = List.objects.filter(user=request.user)
   return render_to_response('base.html', {'lists': lists})

This directs them to the login page:
LOGIN_URL = '/todone/list/login/'
LOGIN_REDIRECT_URL = '/todone/list/'

Which is correctly handled by the django auth default:
(r'^todone/list/login/$', 'django.contrib.auth.views.login'),

I am using the default template from the authentication instructions:

{% extends "base.html" %}

{% block content %}

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

<form method="post" action=".">
<table>
<tr><td><label for="id_username">Username:</label></td><td>{{ form.username
}}</td></tr>
<tr><td><label for="id_password">Password:</label></td><td>{{ form.password
}}</td></tr>
</table>

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

{% endblock %}

When the user logins in with correct credentials, they are redirected to the
expected page.  However in the template, user.is_authenticated is false and
user.username is empty.  But in the views.py, lists =
List.objects.filter(user=request.user) will return the expected results.
Even though the user is not authenticated, the request.user object has the
expected values.

Do I need to explicitly call authenticate and login in my own view to
populate the user data?  From what I read, it seems that the
django.contrib.auth.views.login does that automatically.

Thanks.

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

Reply via email to