| 821 | Regroup and CHOICES fields |
| 822 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 823 | |
| 824 | If the "gender" field on the model in this example is a CHOICES field |
| 825 | rather than a foreign key, ``{{ gender.grouper }}`` will display the |
| 826 | choice's keys, rather than its values. Normally one would correct this |
| 827 | by using the :ref:`get_FOO_display() <extra-instance-methods>` method |
| 828 | to return the value. However, this does not work as one might expect |
| 829 | after regroup has processed the data -- it will no longer be possible |
| 830 | to get at the value string. The solution is to apply |
| 831 | ``get_FOO_display()`` against the *input* of regroup, rather than the |
| 832 | output. So call regroup like this instead:: |
| 833 | |
| 834 | {% regroup people by get_gender_display as gender_list %} |
| 835 | |
| 836 | ``{{ gender.grouper }}`` will now display the value fields from the |
| 837 | CHOICES set rather than the keys. |
| 838 | |
| 839 | |