1👍
✅
As you’ve said, affected_segment
is a many-to-many field. That means it refers to many segments (and the name seems wrong, it should be plural). So you can’t just output it, you need to iterate through it:
{% for a in rehabilitationsessions %}
{% for r in a.affected_segment.all %}
{{ r.get_affected_segment_display }}
{% endfor %}
{% endfor %}
See that since the field you’re interested in on AffectedSegment, itself called affected_segment
, has choices assigned, you can use get_affected_segment_display
to display the readable value of the choice.
Source:stackexchange.com