Home > OS >  How to display a different page when user refreshes the current page in Django
How to display a different page when user refreshes the current page in Django

Time:10-19

I am a beginner in Django and I want to display page-y when the user refreshes the page-x

CodePudding user response:

this event not related to django if you want to do that you should trigger refresh page event using JavaScript

and when this event happen you can make JavaScript function run and make this function navigate user to new page or open new window

check this article to better understanding what I mean

best of luck

CodePudding user response:

Pure HTML/ Django answer. Reload in a Web browser will do another GET for the page. If the Django server remembers the context of the last GET, it can choose to do a redirect rather than show the same again. So for example, if it's something in the user's profile:

if request.user.profile.whatever:
    return redirect( 'myapp:anotherpage' )
  • Related