How to: Click button, then do stuff, then show confirmation in Django
Basic question, but I can't find a simple answer anywhere.
What is the best way to do the following in Django:
- User pushes button
- Some Python code gets crunched server-side 开发者_如何学编程
- User sees confirmation page
All the user needs to know is that the server did what he told it to. No input other than the button click.
Thanks in advance for your help.
That's what a Form
is for. You can create a small HTML form with just the button.
The form's action is the URI to which a request is sent.
Django parse the URI and calls a view function.
The function does the work and returns the resulting page.
精彩评论