Hi Guys,
I am using the regroup feature of Django to group by "team", here is my code:
{% regroup show_detail.cast_set.all by team as cast_list %}
<ul>
{% for cast in cast_list %}
<li>{{ cast.grouper }}
<ul>
{% for item in cast.list %}
<li>{{ item.name }} </li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
This works fine. However, the cast.grouper is integer field with choices, typically I would do {{ cast.get_team_display }} to render the text, not the integer. Is there anyway to do this with the grouper? If this helps whats rendering now is this:
- 2
- Craig Mason
- 1
- Lindsay Price
- Nicole Lee
What it actually should be is:
- Creative Team
- Craig Mason
- Starring
- Lindsay Price
- Nicole Lee
Snippet of my model for you as well if this helps. STARRING = 1 CREATIVE = 2
TEAM_TYPE = (
(CREATIVE, 'Starring'),
(STARRING, 'Creative Team'),
)
name = models.CharField(max_length=200)
team = models.IntegerField(blank=True, null=True, choices=TEAM_TYPE)