Fixed #10801 -- Reverted a portion of [10371]. Practicality beats purity in this case. Thanks to bruce@z2a.org for the report. Refs #9771.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10973 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6ad26e6acc
commit
8765615b9b
|
@ -20,7 +20,7 @@ tutorial, so that the template contains an HTML ``<form>`` element:
|
||||||
|
|
||||||
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
|
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
|
||||||
|
|
||||||
<form action="vote/" method="post">
|
<form action="/polls/{{ poll.id }}/vote/" method="post">
|
||||||
{% for choice in poll.choice_set.all %}
|
{% for choice in poll.choice_set.all %}
|
||||||
<input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
|
<input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
|
||||||
<label for="choice{{ forloop.counter }}">{{ choice.choice }}</label><br />
|
<label for="choice{{ forloop.counter }}">{{ choice.choice }}</label><br />
|
||||||
|
@ -36,12 +36,12 @@ A quick rundown:
|
||||||
selects one of the radio buttons and submits the form, it'll send the
|
selects one of the radio buttons and submits the form, it'll send the
|
||||||
POST data ``choice=3``. This is HTML Forms 101.
|
POST data ``choice=3``. This is HTML Forms 101.
|
||||||
|
|
||||||
* We set the form's ``action`` to ``vote/``, and we set ``method="post"``.
|
* We set the form's ``action`` to ``/polls/{{ poll.id }}/vote/``, and we
|
||||||
Using ``method="post"`` (as opposed to ``method="get"``) is very
|
set ``method="post"``. Using ``method="post"`` (as opposed to
|
||||||
important, because the act of submitting this form will alter data
|
``method="get"``) is very important, because the act of submitting this
|
||||||
server-side. Whenever you create a form that alters data server-side, use
|
form will alter data server-side. Whenever you create a form that alters
|
||||||
``method="post"``. This tip isn't specific to Django; it's just good Web
|
data server-side, use ``method="post"``. This tip isn't specific to
|
||||||
development practice.
|
Django; it's just good Web development practice.
|
||||||
|
|
||||||
* ``forloop.counter`` indicates how many times the :ttag:`for` tag has gone
|
* ``forloop.counter`` indicates how many times the :ttag:`for` tag has gone
|
||||||
through its loop
|
through its loop
|
||||||
|
|
Loading…
Reference in New Issue