Django, Redirecting staff from login to the admin site.

Posted by Francisco Gomez on Stack Overflow See other posts from Stack Overflow or by Francisco Gomez
Published on 2010-05-26T07:37:40Z Indexed on 2010/05/26 7:41 UTC
Read the original article Hit count: 321

Filed under:
|
|
|

So my site basically has 2 kinds of ways to login, one of them is for the common users, who get the regular screen that asks them for username and password, the other way its for staff.

The staff login should redirect them to the admin site after logging in, but for some reason the redirect doesnt happen, it stays on the same login page.

I use this condition on the login view.

if user is not None and user.is_active and user.is_staff:
        auth.login(request,user)
        return HttpResponseRedirect("/admin/")

The admin site its up and running in my url configuration and everything, but i dont know if this is the correct way to redirect to the admin site already on session.

Thanks, any help would be appreciated.

© Stack Overflow or respective owner

Related posts about django

Related posts about redirect