[Fixed]-Joining two tables django newbie qustion

1👍

First get all teams that have a league with a name of “atlantic”:

atlanticsoccer = Team.objects.filter(league__name__contains='atlantic')

Then iterate through them in your template and print whatever you want:

<ul>
    {% for team in atlanticsoccer %}
        <li>{{team.location}}</li>
        <li>{{team.team_name}}</li>
        <li>{{team.league.name}}</li>
        <li>{{team.league.sport}}</li>
    {% endfor %}
</ul>
👤nik_m

Leave a comment