Extending django.contrib.auth.views.login ?

364 views
Skip to first unread message

whiteinge

unread,
Feb 13, 2007, 4:46:02 PM2/13/07
to Django users
I'm pretty new to Django, so any advice would really be appreciated,
especially if I'm headed in the wrong direction.

I'm trying to "extend" django.contrib.auth.views.login in the same
fashion as a generic view. I would like to deposit points in a user's
account after a sucessful login. Here's what I've got--inspired by the
Django Book, Generic Views chapter.

def user_login(request):
response django.contrib.auth.views.login(request)
if XXX: # FIXME: how do I check that this was successful?
do database stuff...
return response


On a semi-related note, I'd probably be able to muddle through this on
my own using the Python console, but I don't know how to fake the
'request' variable in that environment; is this easy to do?

Thanks very much,
- whiteinge

whiteinge

unread,
Feb 15, 2007, 9:59:07 PM2/15/07
to Django users
Easily solved the problem once I realized the difference between
HttpRequest and HttpResponse objects (doh!).

In the event another nub is looking to make stuff happen post-
successful login/logout here's the (now obvious) pseudo-code solution:

def user_login(request):
response = django.contrib.auth.views.login(request)
if request.user.is_authenticated():

Reply all
Reply to author
Forward
0 new messages