python - @login_required decorator doesnot work while hitting the back button on browser -



python - @login_required decorator doesnot work while hitting the back button on browser -

this first time using decorator django. able restirct unauthenticated users accessing views. able view page loggin in perfect when nail button after loggin out restricted page, goes restricted page.

heres view:

@login_required def dashboard(request): if not request.user.is_authenticated(): homecoming render_to_response('/blog/login.html') category = category.objects.all() homecoming render_to_response('dashboard.html',{'category':category})

settings.py:

#url @login_required decorator utilize login_url = '/blog/login/' #redirect authenticated users login_redirect_url = '/blog/dashboard/'

heres logout view:

def user_logout(request): logout(request) homecoming render_to_response('login.html')

your loggout view should not real view, url route loggout , redirect user view, can forcefulness browser not cache using cache_control decorator.

from django.views.decorators.cache import never_cache @never_cache def myview(request): ...

python django python-decorators login-required

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -