Issue
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(),
}
Solution
Was enough to add filter_horizontal = ['participants'] in admin and it gives selected items in the right like so:
Answered By - Vagner
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.