[1.1.X] Fixed #12503 - form examples don't validate according to w3c
Thanks to skyl for the report. Backport of r12086 from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12087 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5d75b3d5c4
commit
d4f9bff7ef
@ -248,7 +248,7 @@ def comment_form_target():
|
|||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
<form action="{% comment_form_target %}" method="POST">
|
<form action="{% comment_form_target %}" method="post">
|
||||||
"""
|
"""
|
||||||
return comments.get_form_target()
|
return comments.get_form_target()
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from django.template import Template
|
|||||||
|
|
||||||
def post_form_response():
|
def post_form_response():
|
||||||
resp = HttpResponse(content="""
|
resp = HttpResponse(content="""
|
||||||
<html><body><form method="POST"><input type="text" /></form></body></html>
|
<html><body><form method="post"><input type="text" /></form></body></html>
|
||||||
""", mimetype="text/html")
|
""", mimetype="text/html")
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ you can use in the template::
|
|||||||
A complete form might look like::
|
A complete form might look like::
|
||||||
|
|
||||||
{% get_comment_form for event as form %}
|
{% get_comment_form for event as form %}
|
||||||
<form action="{% comment_form_target %}" method="POST">
|
<form action="{% comment_form_target %}" method="post">
|
||||||
{{ form }}
|
{{ form }}
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -178,7 +178,7 @@ You may have noticed that the above example uses another template tag --
|
|||||||
form. This will always return the correct URL that comments should be posted to;
|
form. This will always return the correct URL that comments should be posted to;
|
||||||
you'll always want to use it like above::
|
you'll always want to use it like above::
|
||||||
|
|
||||||
<form action="{% comment_form_target %}" method="POST">
|
<form action="{% comment_form_target %}" method="post">
|
||||||
|
|
||||||
Redirecting after the comment post
|
Redirecting after the comment post
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -355,7 +355,7 @@ The ``manage_articles.html`` template might look like this:
|
|||||||
|
|
||||||
.. code-block:: html+django
|
.. code-block:: html+django
|
||||||
|
|
||||||
<form method="POST" action="">
|
<form method="post" action="">
|
||||||
{{ formset.management_form }}
|
{{ formset.management_form }}
|
||||||
<table>
|
<table>
|
||||||
{% for form in formset.forms %}
|
{% for form in formset.forms %}
|
||||||
@ -369,7 +369,7 @@ with the management form:
|
|||||||
|
|
||||||
.. code-block:: html+django
|
.. code-block:: html+django
|
||||||
|
|
||||||
<form method="POST" action="">
|
<form method="post" action="">
|
||||||
<table>
|
<table>
|
||||||
{{ formset }}
|
{{ formset }}
|
||||||
</table>
|
</table>
|
||||||
|
@ -172,7 +172,7 @@ Forms are designed to work with the Django template language. In the above
|
|||||||
example, we passed our ``ContactForm`` instance to the template using the
|
example, we passed our ``ContactForm`` instance to the template using the
|
||||||
context variable ``form``. Here's a simple example template::
|
context variable ``form``. Here's a simple example template::
|
||||||
|
|
||||||
<form action="/contact/" method="POST">
|
<form action="/contact/" method="post">
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<input type="submit" value="Submit" />
|
<input type="submit" value="Submit" />
|
||||||
</form>
|
</form>
|
||||||
@ -183,7 +183,7 @@ The form only outputs its own fields; it is up to you to provide the surrounding
|
|||||||
``form.as_p`` will output the form with each form field and accompanying label
|
``form.as_p`` will output the form with each form field and accompanying label
|
||||||
wrapped in a paragraph. Here's the output for our example template::
|
wrapped in a paragraph. Here's the output for our example template::
|
||||||
|
|
||||||
<form action="/contact/" method="POST">
|
<form action="/contact/" method="post">
|
||||||
<p><label for="id_subject">Subject:</label>
|
<p><label for="id_subject">Subject:</label>
|
||||||
<input id="id_subject" type="text" name="subject" maxlength="100" /></p>
|
<input id="id_subject" type="text" name="subject" maxlength="100" /></p>
|
||||||
<p><label for="id_message">Message:</label>
|
<p><label for="id_message">Message:</label>
|
||||||
@ -211,7 +211,7 @@ If the default generated HTML is not to your taste, you can completely customize
|
|||||||
the way a form is presented using the Django template language. Extending the
|
the way a form is presented using the Django template language. Extending the
|
||||||
above example::
|
above example::
|
||||||
|
|
||||||
<form action="/contact/" method="POST">
|
<form action="/contact/" method="post">
|
||||||
<div class="fieldWrapper">
|
<div class="fieldWrapper">
|
||||||
{{ form.subject.errors }}
|
{{ form.subject.errors }}
|
||||||
<label for="id_subject">E-mail subject:</label>
|
<label for="id_subject">E-mail subject:</label>
|
||||||
@ -263,7 +263,7 @@ If you're using the same HTML for each of your form fields, you can reduce
|
|||||||
duplicate code by looping through each field in turn using a ``{% for %}``
|
duplicate code by looping through each field in turn using a ``{% for %}``
|
||||||
loop::
|
loop::
|
||||||
|
|
||||||
<form action="/contact/" method="POST">
|
<form action="/contact/" method="post">
|
||||||
{% for field in form %}
|
{% for field in form %}
|
||||||
<div class="fieldWrapper">
|
<div class="fieldWrapper">
|
||||||
{{ field.errors }}
|
{{ field.errors }}
|
||||||
@ -322,7 +322,7 @@ and visible fields independently: ``hidden_fields()`` and
|
|||||||
``visible_fields()``. Here's a modification of an earlier example that uses
|
``visible_fields()``. Here's a modification of an earlier example that uses
|
||||||
these two methods::
|
these two methods::
|
||||||
|
|
||||||
<form action="/contact/" method="POST">
|
<form action="/contact/" method="post">
|
||||||
{% for field in form.visible_fields %}
|
{% for field in form.visible_fields %}
|
||||||
<div class="fieldWrapper">
|
<div class="fieldWrapper">
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ If your site uses the same rendering logic for forms in multiple places, you
|
|||||||
can reduce duplication by saving the form's loop in a standalone template and
|
can reduce duplication by saving the form's loop in a standalone template and
|
||||||
using the :ttag:`include` tag to reuse it in other templates::
|
using the :ttag:`include` tag to reuse it in other templates::
|
||||||
|
|
||||||
<form action="/contact/" method="POST">
|
<form action="/contact/" method="post">
|
||||||
{% include "form_snippet.html" %}
|
{% include "form_snippet.html" %}
|
||||||
<p><input type="submit" value="Send message" /></p>
|
<p><input type="submit" value="Send message" /></p>
|
||||||
</form>
|
</form>
|
||||||
@ -373,7 +373,7 @@ using the :ttag:`include` tag to reuse it in other templates::
|
|||||||
If the form object passed to a template has a different name within the
|
If the form object passed to a template has a different name within the
|
||||||
context, you can alias it using the :ttag:`with` tag::
|
context, you can alias it using the :ttag:`with` tag::
|
||||||
|
|
||||||
<form action="/comments/add/" method="POST">
|
<form action="/comments/add/" method="post">
|
||||||
{% with comment_form as form %}
|
{% with comment_form as form %}
|
||||||
{% include "form_snippet.html" %}
|
{% include "form_snippet.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
@ -697,14 +697,14 @@ There are three ways to render a formset in a Django template.
|
|||||||
|
|
||||||
First, you can let the formset do most of the work::
|
First, you can let the formset do most of the work::
|
||||||
|
|
||||||
<form method="POST" action="">
|
<form method="post" action="">
|
||||||
{{ formset }}
|
{{ formset }}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
Second, you can manually render the formset, but let the form deal with
|
Second, you can manually render the formset, but let the form deal with
|
||||||
itself::
|
itself::
|
||||||
|
|
||||||
<form method="POST" action="">
|
<form method="post" action="">
|
||||||
{{ formset.management_form }}
|
{{ formset.management_form }}
|
||||||
{% for form in formset.forms %}
|
{% for form in formset.forms %}
|
||||||
{{ form }}
|
{{ form }}
|
||||||
@ -717,7 +717,7 @@ form as shown above. See the :ref:`management form documentation
|
|||||||
|
|
||||||
Third, you can manually render each field::
|
Third, you can manually render each field::
|
||||||
|
|
||||||
<form method="POST" action="">
|
<form method="post" action="">
|
||||||
{{ formset.management_form }}
|
{{ formset.management_form }}
|
||||||
{% for form in formset.forms %}
|
{% for form in formset.forms %}
|
||||||
{% for field in form %}
|
{% for field in form %}
|
||||||
@ -730,7 +730,7 @@ If you opt to use this third method and you don't iterate over the fields with
|
|||||||
a ``{% for %}`` loop, you'll need to render the primary key field. For example,
|
a ``{% for %}`` loop, you'll need to render the primary key field. For example,
|
||||||
if you were rendering the ``name`` and ``age`` fields of a model::
|
if you were rendering the ``name`` and ``age`` fields of a model::
|
||||||
|
|
||||||
<form method="POST" action="">
|
<form method="post" action="">
|
||||||
{{ formset.management_form }}
|
{{ formset.management_form }}
|
||||||
{% for form in formset.forms %}
|
{% for form in formset.forms %}
|
||||||
{{ form.id }}
|
{{ form.id }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user