mirror of https://github.com/django/django.git
Cleaned up the docs from [4830] a bit.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4831 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d6fd9fb22b
commit
45f9217cbd
|
@ -877,16 +877,17 @@ with
|
||||||
|
|
||||||
**New in Django development version**
|
**New in Django development version**
|
||||||
|
|
||||||
Useful for caching a method which will be used more than once.
|
Caches a complex variable under a simpler name. This is useful when accessing
|
||||||
|
an "expensive" method (e.g. one that hits the database) multiple times.
|
||||||
|
|
||||||
For example::
|
For example::
|
||||||
|
|
||||||
{% with person.some_sql_method as total %}
|
{% with business.employees.count as total %}
|
||||||
{{ total }} person object{{ total|pluralize }}
|
{{ total }} employee{{ total|pluralize }}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
The populated variable (in the example above, ``total``) is only available
|
The populated variable (in the example above, ``total``) is only available
|
||||||
inside of ``{% with %}`` block.
|
inside of the ``{% with %}`` block.
|
||||||
|
|
||||||
Built-in filter reference
|
Built-in filter reference
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
Loading…
Reference in New Issue