Monday, May 23, 2011

Implement su (i.e. substitute user) in Django

Hello,

for my little site there are a couple of different types of users, and
the view presented to the user differs depending on what type of user
this is. For me (as a super user) - it would be very convenient If I
could change identity and become another user, without having to log
out and log in again. My super-naive first attempt was just like this:


def su_view( request ):
new_user = User.objects.get( pk = 10 ) # Hardcoded id = 10
request.user = new_user
return HttpResonpseRedirect("/")

But that did not work (not very surprising ...). Is what I try do at
all possible? Any hints on how to achieve this?

Regards Joakim

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment