Ticket #13452: regroup-choices-3.diff

File regroup-choices-3.diff, 1.5 KB (added by Scot Hacker, 14 years ago)

Modified patch to be more inclusive of regroupable properties

  • docs/ref/models/instances.txt

     
    515515More details on named URL patterns are in the :ref:`URL dispatch documentation
    516516<topics-http-urls>`.
    517517
     518.. _extra-instance-methods:
     519
    518520Extra instance methods
    519521======================
    520522
  • docs/ref/templates/builtins.txt

     
    825825
    826826    {% regroup people|dictsort:"gender" by gender as gender_list %}
    827827
     828
     829Grouping on other properties
     830^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     831
     832Any valid template lookup is a legal grouping attribute for the regroup
     833tag, including methods, attributes, dictionary keys and list items. For
     834example, if the "gender" field is a foreign key to a class with
     835an attribute "description," you could use::
     836
     837    {% regroup people by gender.description as gender_list %}
     838
     839Or, if the "gender" field is a CHOICES field rather than a foreign key,
     840it will naturally have a :ref:`get_FOO_display()
     841<extra-instance-methods>` method available as an attribute, allowing
     842you to group on the display string rather than the CHOICES key::
     843
     844    {% regroup people by get_gender_display as gender_list %}
     845
     846``{{ gender.grouper }}`` will now display the value fields from the
     847CHOICES set rather than the keys.
     848
    828849.. templatetag:: spaceless
    829850
    830851spaceless
Back to Top