diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 125cd9ed55..0b039a5e00 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -936,7 +936,8 @@ def ifchanged(parser, token): """ Checks if a value has changed from the last iteration of a loop. - The 'ifchanged' block tag is used within a loop. It has two possible uses. + The ``{% ifchanged %}`` block tag is used within a loop. It has two + possible uses. 1. Checks its own rendered contents against its previous state and only displays the content if it has changed. For example, this displays a @@ -949,9 +950,9 @@ def ifchanged(parser, token): {{ date|date:"j" }} {% endfor %} - 2. If given a variable, check whether that variable has changed. - For example, the following shows the date every time it changes, but - only shows the hour if both the hour and the date have changed:: + 2. If given one or more variables, check whether any variable has changed. + For example, the following shows the date every time it changes, while + showing the hour if either the hour or the date has changed:: {% for date in days %} {% ifchanged date.date %} {{ date.date }} {% endifchanged %} diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 3638ce9078..6850f0504f 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -555,7 +555,8 @@ ifchanged Check if a value has changed from the last iteration of a loop. -The 'ifchanged' block tag is used within a loop. It has two possible uses. +The ``{% ifchanged %}`` block tag is used within a loop. It has two possible +uses. 1. Checks its own rendered contents against its previous state and only displays the content if it has changed. For example, this displays a list of @@ -568,9 +569,9 @@ The 'ifchanged' block tag is used within a loop. It has two possible uses. {{ date|date:"j" }} {% endfor %} -2. If given a variable, check whether that variable has changed. For - example, the following shows the date every time it changes, but - only shows the hour if both the hour and the date has changed:: +2. If given one or more variables, check whether any variable has changed. + For example, the following shows the date every time it changes, while + showing the hour if either the hour or the date has changed:: {% for date in days %} {% ifchanged date.date %} {{ date.date }} {% endifchanged %}