diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt index 5cc76bdee8..a8ae0ef922 100644 --- a/docs/topics/forms/index.txt +++ b/docs/topics/forms/index.txt @@ -249,6 +249,44 @@ over them:: {% endfor %} {% endif %} + +Looping over the form's fields +------------------------------ + +If you are using the similar HTML for each of your form fields, you can +reduce duplicate code by looping through each field in turn using +``{% for field in form %}``:: + +
+ {% for field in form %} +
+ {{ field.errors }} + {{ field.label_tag }}: {{ field }} +
+ {% endfor %} +

+
+ +As in the above example, {{ field.errors }} will output a +``