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:

enter image description here

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(),
        }
Asked By: Vagner

||

Answers:

Was enough to add filter_horizontal = ['participants'] in admin and it gives selected items in the right like so: enter image description here

Answered By: Vagner
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.