M2M through listing on source model

2 views
Skip to first unread message

Lachlan Musicman

unread,
Aug 9, 2017, 2:16:09 AM8/9/17
to django...@googlegroups.com
I have a situation where there is a M2M with a through model for extra information, as per
https://docs.djangoproject.com/en/1.11/topics/db/models/#extra-fields-on-many-to-many-relationships

When using Class Based Generic Views in the documented situation above, how would I show a list of members for each group?

I have something like

{% for membership in group.membership.all %}
{{ membership__person_name }}
{{ membership_start_date }}
{% endfor %}

but it's not working. Obv I'm doing something wrong/stupid, but nothing I'm trying seems to work and the docs suggest I need to come through the membership object. Which would be fine, but surely the details are available to the Group object?

Cheers
L.
------
"The antidote to apocalypticism is apocalyptic civics. Apocalyptic civics is the insistence that we cannot ignore the truth, nor should we panic about it. It is a shared consciousness that our institutions have failed and our ecosystem is collapsing, yet we are still here — and we are creative agents who can shape our destinies. Apocalyptic civics is the conviction that the only way out is through, and the only way through is together. "

Greg Bloom @greggish https://twitter.com/greggish/status/873177525903609857
Reply all
Reply to author
Forward
0 new messages