vikrant vikrant - 1 month ago 24
Python Question

Url for Remember me Option in Django

In my django project i want to use remember me option.Now if user hit

localhost/home
it redirect to home page of that user.If user hit only
localhost/
it is not.

Localhost/
is the url of my project home page where user can find login and registration.

If already logged in user exist and user hit
localhost/
urlit should take user to
localhost/home

Answer

If already logged in user exist and user hit localhost/ urlit should take user to localhost/home

You have to program it.

def index(request):
    if request.user.is_authenticated():
        return redirect('/home/')