problem with sessions docs?

0 views
Skip to first unread message

Bryan Murdock

unread,
Nov 12, 2005, 10:38:31 PM11/12/05
to django...@googlegroups.com
The example code for logging a user in here:

http://www.djangoproject.com/documentation/sessions/

is this:

def login(request):
u = users.get_object(username__exact=request.POST['username'])
if u.check_password(request.POST['password']):
request.session['user_id'] = u.id
return HttpResponse("You're logged in.")
else:
return HttpResponse("Your username and password didn't match.")

It doesn't work for me. I googled and found some code here:

http://cvd.cidev.nl/wordpress/?p=245

That basically makes one small change resulting in this:

def login(request):
u = users.get_object(username__exact=request.POST['username'])
if u.check_password(request.POST['password']):

# CHANGE: different key used:
request.session[users.SESSION_KEY] = u.id
return HttpResponse("You're logged in.")
else:
return HttpResponse("Your username and password didn't match.")

Which then works for me. Is this an error in the docs? Maybe I need to svn up?

Thanks,

Bryan

Adrian Holovaty

unread,
Nov 12, 2005, 11:43:56 PM11/12/05
to django...@googlegroups.com
On 11/12/05, Bryan Murdock <bmur...@gmail.com> wrote:
> The example code for logging a user in here:
>
> http://www.djangoproject.com/documentation/sessions/
> [...]
> It doesn't work for me. I googled and found some code here:
> [...]
> Is this an error in the docs? Maybe I need to svn up?

Hey Bryan,

This technically isn't an error in the docs; it's just a bit
misleading. The "user" in that example wasn't intended to be the user
from the authentication framework -- it's just some generic concept of
"user."

I've changed the example to use "member" instead of "user," to
underscore the fact that it's some random concept of "member" -- not
the "users" from the authentication system.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org

Bryan Murdock

unread,
Nov 12, 2005, 11:49:17 PM11/12/05
to django...@googlegroups.com
On 11/12/05, Adrian Holovaty <holo...@gmail.com> wrote:
> Hey Bryan,
>
> This technically isn't an error in the docs; it's just a bit
> misleading. The "user" in that example wasn't intended to be the user
> from the authentication framework -- it's just some generic concept of
> "user."
>
> I've changed the example to use "member" instead of "user," to
> underscore the fact that it's some random concept of "member" -- not
> the "users" from the authentication system.

Ahhh, now I see. Thanks!

Bryan
Reply all
Reply to author
Forward
0 new messages