商業,創業,美食,葡萄酒,閱讀,網路科技。
這是我的 FB粉專 以及 IG,我比較常使用 Threads,歡迎大家追蹤互動~
https://docs.djangoproject.com/en/1.6/intro/tutorial04/
首先是 HTML form 的 method 屬性, 節錄上面 tutorial 4 的兩段:
“We set the form’s action to {% url ‘polls:vote’ poll.id %}, and we set method=”post”. Using method=”post” (as opposed to method=”get”) is very important, because the act of submitting this form will alter data server-side. Whenever you create a form that alters data server-side, use method=”post”. This tip isn’t specific to Django; it’s just good Web development practice.”
“Since we’re creating a POST form (which can have the effect of modifying data), we need to worry about Cross Site Request Forgeries. Thankfully, you don’t have to worry too hard, because Django comes with a very easy-to-use system for protecting against it. In short, all POST forms that are targeted at internal URLs should use the {% csrf_token %} template tag.”
“As the Python comment above points out, you should always return an HttpResponseRedirect after successfully dealing with POST data. This tip isn’t specific to Django; it’s just good Web development practice.”
“These views represent a common case of basic Web development: getting data from the database according to a parameter passed in the URL, loading a template and returning the rendered template. Because this is so common, Django provides a shortcut, called the “generic views” system.”
商業,創業,美食,葡萄酒,閱讀,網路科技。