From ec5659382a5f5fc2daf0c87ccc89d0fb07534874 Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 5 May 2022 09:21:47 +0200 Subject: Fixed #32339 -- Added div.html form template. --- docs/ref/forms/api.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'docs/ref/forms') diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 8530af2611..72937bfa9a 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -607,6 +607,55 @@ list using ``{{ form.as_ul }}``. Each helper pairs a form method with an attribute giving the appropriate template name. +``as_div()`` +~~~~~~~~~~~~ + +.. attribute:: Form.template_name_div + +.. versionadded:: 4.1 + +The template used by ``as_div()``. Default: ``'django/forms/div.html'``. + +.. method:: Form.as_div() + +.. versionadded:: 4.1 + +``as_div()`` renders the form as a series of ``
`` elements, with each +``
`` containing one field, such as: + +.. code-block:: pycon + + >>> f = ContactForm() + >>> f.as_div() + +… gives HTML like: + +.. code-block:: html + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +.. note:: + + Of the framework provided templates and output styles, ``as_div()`` is + recommended over the ``as_p()``, ``as_table()``, and ``as_ul()`` versions + as the template implements ``
`` and ```` to group related + inputs and is easier for screen reader users to navigate. + ``as_p()`` ~~~~~~~~~~ -- cgit v1.3