Logout, Clear Cache, and Prevent Back Navigation to Previous Window
Currently, I have a few view that is called unlogin and login:
views.py
@cache_control(no_cache = True, must_revalidate = True, no_store= True)
def unlogin(request):
logout(request)
response = redirect('main')
response['Cache-Control'] = 'no-cache, no-store, must-revalidate'
response['Pragma'] = 'no-cache'
response['Expires'] = 0
return response
def login(request)
form = formfill()
# User fills form and processing
user = authenticate(request, username=username, password=password)
if user:
login(request, user=user)
return redirect('signedinpage')
return render(request, 'myloginpage.html', {'form1': form})
def success(request):
# Process logout
return render(request,'signinginpagecomplete.html')
On urls.py I have:
urlpatterns = [ path('unlogin/',view=views.unlogin, name="unlogin"), path('mylogin/', view=views.login, name="mylogin"), path="signedinpage/" views=view.success, name="signedinpage"]
I am expecting that when I press the logout button that is in success view, I will logout the user and the user will not be able to go back to the previous page. But it is not happening, I was wondering if the logout processing should happen under the success function?