ThunderHorn
ThunderHorn

Reputation: 2035

Django: After logging out if i press the back button will go back to the web page

here is my logout view since its redirecting to my home page, after clicking on the browser's back button will generate the page that was visited before. How can i prevent that from happening?

def logout_page(request):
    logout(request)
    messages.success(request, msg_from_db('goodbye'))
    return HttpResponseRedirect('/')

Upvotes: 0

Views: 2073

Answers (2)

himayat ullah
himayat ullah

Reputation: 1

use django views decorators cache for your views

from django.views.decorators.cache import cache_control
from django.contrib.auth.decorators import login_required

@login_required(login_url='/')
@cache_control(no_cache=True, must_revalidate=True, no_store=True)
def home(request):
   # your code

Upvotes: 0

Shihabudheen K M
Shihabudheen K M

Reputation: 1397

use login_required decorator for your protected views

from django.contrib.auth.decorators import login_required

@login_required
def home(request):
   # your code

Upvotes: 2

Related Questions