Ticket #13452: regroup-choices-2.diff

File regroup-choices-2.diff, 1.3 KB (added by shacker, 5 years ago)

Documentation clarified

  • 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
     828Note that *methods* are also valid arguments to the regroup tag. For
     829example, if the "gender" field on the model in this example is a CHOICES
     830field rather than a foreign key, ``{{ gender.grouper }}`` will naturally
     831have a :ref:`get_FOO_display() <extra-instance-methods>` method
     832available as an attribute, so you can group on the display string
     833rather than the CHOICES key::
     834
     835    {% regroup people by get_gender_display as gender_list %}
     836
     837``{{ gender.grouper }}`` will now display the value fields from the
     838CHOICES set rather than the keys.
     839
    828840.. templatetag:: spaceless
    829841
    830842spaceless
Back to Top