tags:

views:

38

answers:

2
+1  A: 

In you use login view, on successful login you should redirect to the page you want user to land on e.g.

def login_view(request):
    if not correct_login:
        pass#return response with errors
    else
        return HttpResponseRedirect("/welcome")

see HttpResponseRedirect or use redirect shortcut.

Anurag Uniyal
+1  A: 

If you use the built-in Django authentication, you can redirect after login or logout by using the built-in functions. You can redirect to a specific page or you can redirect them to the page they were trying to access.

For example, the doc above uses the following example in using the login_required decorator:

from django.contrib.auth.decorators import login_required

@login_required(redirect_field_name='redirect_to')
def my_view(request):
    ...

I highly recommend checking out the above doc. When I first setup Django's authentication, I was impressed that it only took me about 30 minutes to set it up the way I wanted it, and most of that time was reading the above page.

Tony Guinta