Login page issue

Hi everyone,

Can any one suggest me, I have login form once I logged in successfully if I hit back button in browser its going back to previous page ie., login page
How to prevent it.

Check if the user is authenticated and redirect is they are.

def login_view(request):
    #check if user is authenticated 
    if request.user.is_authenticated():
        return reverse(“home”)
     #other login logic for unauthenticated users

This is assuming you have a url pattern named “home”. You can redirect them to whatever page you’d like if they are authenticated.