diff --git a/django/contrib/comments/templatetags/comments.py b/django/contrib/comments/templatetags/comments.py index 8e62f91eed..42691c63e4 100644 --- a/django/contrib/comments/templatetags/comments.py +++ b/django/contrib/comments/templatetags/comments.py @@ -306,7 +306,7 @@ def comment_form_target(): Example:: -
+ """ return comments.get_form_target() diff --git a/docs/ref/contrib/comments/example.txt b/docs/ref/contrib/comments/example.txt index e9445353ca..ec600f7219 100644 --- a/docs/ref/contrib/comments/example.txt +++ b/docs/ref/contrib/comments/example.txt @@ -103,7 +103,7 @@ But let's look at a simple example:: - + {{ form }} diff --git a/docs/ref/contrib/comments/index.txt b/docs/ref/contrib/comments/index.txt index 9f53f06299..319dadff08 100644 --- a/docs/ref/contrib/comments/index.txt +++ b/docs/ref/contrib/comments/index.txt @@ -218,7 +218,7 @@ you can use in the template:: A complete form might look like:: {% get_comment_form for event as form %} - + {{ form }} @@ -239,7 +239,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; you'll always want to use it like above:: - + Redirecting after the comment post ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/ref/contrib/csrf.txt b/docs/ref/contrib/csrf.txt index ea76fc3739..e635a0380b 100644 --- a/docs/ref/contrib/csrf.txt +++ b/docs/ref/contrib/csrf.txt @@ -49,7 +49,7 @@ To enable CSRF protection for your views, follow these steps: 2. In any template that uses a POST form, use the :ttag:`csrf_token` tag inside the ```` element if the form is for an internal URL, e.g.:: - {% csrf_token %} + {% csrf_token %} This should not be done for POST forms that target external URLs, since that would cause the CSRF token to be leaked, leading to a vulnerability. diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index e6146aeaba..974a5ca251 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -355,7 +355,7 @@ The ``manage_articles.html`` template might look like this: .. code-block:: html+django - + {{ formset.management_form }}
{% for form in formset.forms %} @@ -369,7 +369,7 @@ with the management form: .. code-block:: html+django - +
{{ formset }}
diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt index 0de5a6b8cb..119e943889 100644 --- a/docs/topics/forms/index.txt +++ b/docs/topics/forms/index.txt @@ -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 context variable ``form``. Here's a simple example template:: - + {{ form.as_p }}
@@ -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 wrapped in a paragraph. Here's the output for our example template:: -
+

@@ -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 above example:: - +

{{ form.subject.errors }} @@ -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 %}`` loop:: - + {% for field in form %}
{{ 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 these two methods:: - + {% for field in form.visible_fields %}
@@ -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 using the :ttag:`include` tag to reuse it in other templates:: - + {% include "form_snippet.html" %}

@@ -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 context, you can alias it using the :ttag:`with` tag:: -
+ {% with comment_form as form %} {% include "form_snippet.html" %} {% endwith %} diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index 024479508a..7049464f86 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -705,14 +705,14 @@ There are three ways to render a formset in a Django template. First, you can let the formset do most of the work:: - + {{ formset }}
Second, you can manually render the formset, but let the form deal with itself:: -
+ {{ formset.management_form }} {% for form in formset.forms %} {{ form }} @@ -725,7 +725,7 @@ form as shown above. See the :ref:`management form documentation Third, you can manually render each field:: - + {{ formset.management_form }} {% for form in formset.forms %} {% for field in form %} @@ -738,7 +738,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, if you were rendering the ``name`` and ``age`` fields of a model:: - + {{ formset.management_form }} {% for form in formset.forms %} {{ form.id }} diff --git a/tests/regressiontests/csrf_tests/tests.py b/tests/regressiontests/csrf_tests/tests.py index 5688293647..0a24522d9c 100644 --- a/tests/regressiontests/csrf_tests/tests.py +++ b/tests/regressiontests/csrf_tests/tests.py @@ -13,7 +13,7 @@ from django.template import RequestContext, Template # Response/views used for CsrfResponseMiddleware and CsrfViewMiddleware tests def post_form_response(): resp = HttpResponse(content=""" -
+
""", mimetype="text/html") return resp