How to get only selected items from admin CheckboxSelectMultiple Django
Question:
I am trying to display only selected participants from admin panel but ending up getting all of them.
My admin panel looks like this:
These are the team captains so when they are joining the tournament the template shows their team
my template looks like this:
{% for team in teams %}
{% for player in tournament.participants.all %}
{% for member in team.members.all %}
{{ member.username }}
{% endfor %}
{% endfor %}
{% endfor %}
And admin.py
class TournamentAdminForm(ModelForm):
class Meta:
model = Tournament
fields = '__all__'
widgets = {
"participants": CheckboxSelectMultiple(),
"broadcast_talents": CheckboxSelectMultiple(),
}
Answers:
I am trying to display only selected participants from admin panel but ending up getting all of them.
My admin panel looks like this:
These are the team captains so when they are joining the tournament the template shows their team
my template looks like this:
{% for team in teams %}
{% for player in tournament.participants.all %}
{% for member in team.members.all %}
{{ member.username }}
{% endfor %}
{% endfor %}
{% endfor %}
And admin.py
class TournamentAdminForm(ModelForm):
class Meta:
model = Tournament
fields = '__all__'
widgets = {
"participants": CheckboxSelectMultiple(),
"broadcast_talents": CheckboxSelectMultiple(),
}