diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2013-11-06 00:17:28 +0100 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2013-11-06 00:26:58 +0100 |
| commit | b914991b3705cb6c91013d962c55cda9deb18d83 (patch) | |
| tree | 702b997c0951bc36dafbf89ecd8c94679fce1427 /docs/ref | |
| parent | c349bcbdf9c3520a0050bddf49ea59d9418c3ecb (diff) | |
Added more tests and documentation for dictsort.
It's possible to use something like {{ foo|dictsort:'bar.baz' }}
but this wasn't tested or documented.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/templates/builtins.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 48412239ad..d8f76dc680 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -1433,6 +1433,27 @@ then the output would be: {'name': 'zed', 'age': 19}, ] +You can also do more complicated things like:: + {{ for book in books|dictsort:"author.age" + * {{ book.title }} ({{ book.author.name }}) + {% endfor %} + +If ``books`` is: + +.. code-block:: python + + [ + {'title': '1984', 'author': {'name': 'George', 'age': 45}}, + {'title': 'Timequake', 'author': {'name': 'Kurt', 'age': 75}}, + {'title': 'Alice', 'author': {'name': 'Lewis', 'age': 33}}, + ] + +the the output would be:: + + * Alice (Lewis) + * 1984 (George) + * Timequake (Kurt) + .. templatefilter:: dictsortreversed dictsortreversed |
