I have a three ‘layers’ deep model, that i’s like to access through my template:
Models:
class Match(models.Model):
pl1 = models.IntegerField(default=0)
pl2 = models.IntegerField(default=0)
boards = models.ManyToManyField(Scoreboard)
active = models.IntegerField(default=1)
turn = models.IntegerField(default=0)
def __unicode__(self):
return "Match " + str(self.id)
class Scoreboard(models.Model):
user = models.ForeignKey(User)
I’m just guessing, but to get the names of the users connected to each ‘Match’, shouldn’t it be something like this:
{% for active in matches %}
{{active}} - {{active.boards.user}}<br>
{% endfor %}
boardsis the ManyToMany, so there are many scoreboards to eachmatch. So, you need to iterate through them.