title: Django dynamically filter list in template
body: <p>I have a page which lists all of the <code>athletes</code> that a certain <code>coach</code> has.  Coaches, however, can have multiple teams and I am trying to allow them to select a team from a dropdown at the top of the page and dynamically filter the list of athletes to only show those on the selected team.</p>
  
  <p>My template:</p>
  
  <pre><code>&lt;table class='table'&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;h3&gt;Team&lt;/h3&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;h3&gt;First Name&lt;/h3&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;h3&gt;Last Name&lt;/h3&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;h3&gt;Email&lt;/h3&gt;&lt;/td&gt;
              &lt;/tr&gt;
              {% for athlete in athletes %}
                  {% if not athlete.coach_ind %}
                  &lt;tr&gt;&lt;td&gt;
                          {% for team in athlete.team.all %}
                              {{ team.school }} {{ team.mascot }} {{ team.sport }}
                          {% endfor %}
                      &lt;/td&gt;
  
                      &lt;td&gt;{{ athlete.user.first_name }}&lt;/td&gt;
                      &lt;td&gt;{{ athlete.user.last_name }}&lt;/td&gt;
                      &lt;td&gt;{{ athlete.user.email }}&lt;/td&gt;
                  &lt;/tr&gt;
                  {% endif %}
              {% endfor %}
          &lt;/table&gt;
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>teams_list = request.user.profile.team.all()
  athletes = UserProfile.objects.filter(team__in=teams_list).order_by('team','user__last_name')
  </code></pre>
  
  <p>I am able to successfully get the correct list of all athletes and their information, I'm just not sure how to create a dynamic filter to show only by team.</p>