Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13452 - Document that regroup can be used with any template lo…

…okup. Thanks shacker for the suggestion and draft patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15108 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 032aac72c4ea70adcfa7b985088bf2dd9e563ad5 1 parent 4243d49
Tim Graham authored December 29, 2010

Showing 1 changed file with 23 additions and 2 deletions. Show diff stats Hide diff stats

  1. 25  docs/ref/templates/builtins.txt
25  docs/ref/templates/builtins.txt
@@ -800,6 +800,27 @@ filter, if your data is in a list of dictionaries::
800 800
 
801 801
     {% regroup people|dictsort:"gender" by gender as gender_list %}
802 802
 
  803
+
  804
+Grouping on other properties
  805
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  806
+
  807
+Any valid template lookup is a legal grouping attribute for the regroup
  808
+tag, including methods, attributes, dictionary keys and list items. For
  809
+example, if the "gender" field is a foreign key to a class with
  810
+an attribute "description," you could use::
  811
+
  812
+    {% regroup people by gender.description as gender_list %}
  813
+
  814
+Or, if ``gender`` is a field with ``choices``, it will have a
  815
+:meth:`~django.db.models.Model.get_FOO_display` method available as an
  816
+attribute, allowing  you to group on the display string rather than the
  817
+``choices`` key::
  818
+
  819
+    {% regroup people by get_gender_display as gender_list %}
  820
+
  821
+``{{ gender.grouper }}`` will now display the value fields from the
  822
+``choices`` set rather than the keys.
  823
+
803 824
 .. templatetag:: spaceless
804 825
 
805 826
 spaceless
@@ -2074,7 +2095,7 @@ urlize
2074 2095
 
2075 2096
 Converts URLs in text into clickable links.
2076 2097
 
2077  
-Works on links beginning with ``http://``, ``https://``, or ``www.`` and 
  2098
+Works on links beginning with ``http://``, ``https://``, or ``www.`` and
2078 2099
 ending with ``.org``, ``.net`` or ``.com``. Links can have trailing punctuation
2079 2100
 (periods, commas, close-parens) and leading punctuation (opening parens) and
2080 2101
 ``urlize`` will still do the right thing.
@@ -2108,7 +2129,7 @@ urlizetrunc
2108 2129
 Converts URLs into clickable links just like urlize_, but truncates URLs
2109 2130
 longer than the given character limit.
2110 2131
 
2111  
-**Argument:** Number of characters that link text should be truncated to, 
  2132
+**Argument:** Number of characters that link text should be truncated to,
2112 2133
 including the ellipsis that's added if truncation is necessary.
2113 2134
 
2114 2135
 For example::

0 notes on commit 032aac7

Please sign in to comment.
Something went wrong with that request. Please try again.