[Django]-Query in ManyToMany relation

5👍

Looking at your models:

class PlayerTournament(models.Model):
    player = models.ForeignKey(Tournament)
    tournament = models.ForeignKey(Player)

You have player and tournament interchanged

You should be doing:

PlayerTournament.objects.filter(player__title = "Winter").values()

and if you are indeed looking for related fields, you should be using select_related or prefetch_related instead of values (Which I highly doubt based on your quqery)

Leave a comment