I’d like to know if anyone knows:
For example, I have a form that user fills in, and when he submits, the page will redirect to “thank you” page. Everything works fine. In urls.py I had this line pointing that the page exists:
url(r'^thankyou/$', 'render_form'),
But then, when I type in url mysite.com/thankyou/, the page “Thank you” appears… But I need it to appear only when I submit a form and hide it when user tries to open it directly.
Please help. Thanks in advance!
You could put something in the session in your form handling view before redirecting, and check it in the thank-you URL: if it’s not there, then return a 403 error. Something like:
Note I’m using
popin thank_you to ensure that the key is deleted from the session no matter what.