Greetings, I'm having problem showing from the value a sub model. I have a main model (team) I'm displaying the information, a team contain a list players and these are listed in the page too. So far so good, but here where its doesn't work, players have skill and vital and I can't get to show them in the team page.
The relation between player and PlayerVital is one to one while the relation with PlayerSkills a foreing key in the playerSkill model mainly because skill evolve in time and we need to keep track of that. I tried many systax in the view but nothing seem to work. It seem something obvious but I can't manage to find it in the doc. Any pointers would be helpfull. thanks, Chris Here my model class Team(models.Model): team_name = models.CharField(max_length=200) city = models.CharField(max_length=200) #propably FK later def __unicode__(self): return self.team_name class Player(models.Model): teamKey = models.ForeignKey(Team, blank=True, null=True) first_name = models.CharField(max_length=200) last_name = models.CharField(max_length=200) def fullname(self): return u'%s %s' % (self.first_name, self.last_name) def __unicode__(self): return self.fullname() class PlayerVital(models.Model): playerKey = models.OneToOneField(Player, primary_key=True) POSITION = ( ('G', 'Goaler'), ('D', 'Defense'), ('C', 'Center'), ('LW', 'Left Wing'), ('RW', 'Right Wing'), ) position=models.CharField(max_length=2, choices=POSITION) #C/RW/LW/ D/G height= models.IntegerField() weight= models.IntegerField() nationality = models.CharField(max_length=200)#propably FK later class PlayerSkills(models.Model): skill_at_date = models.DateField('skill_date') playerKey = models.ForeignKey(Player) SKILL_RANGE = zip( range(0,100), range(0,100)) speed=models.IntegerField(default=50, choices=SKILL_RANGE, blank=True) strength=models.IntegerField(default=50, choices=SKILL_RANGE, blank=True) endurance=models.IntegerField(default=50, choices=SKILL_RANGE, blank=True) Here the template <h1>{{ object.team_name }}</h1> {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} <form action="/hockeySite/{{ object.id }}" method="post"> {% csrf_token %} <table> <tr> <td> Player Name </td> <td> Position </td> <td> speed </td> <td> height </td> </tr> {% for player in object.player_set.all %} <tr> <td> <label for="player{{ forloop.counter }}">{{ player.fullname }}</ label> <!-- OK --> </td> <td> <label for="player{{ forloop.counter }}">{{ player.playerVitals_set.position }} </label> <!-- FAIL --> </td> <td> <label for="player{{ forloop.counter }}">{{ player.player_set.speed }} a</ label> <!-- FAIL --> </td> <td> <label for="player{{ forloop.counter }}">{{ playerVitals.height }} </label> <!-- FAIL --> </td> </tr> {% endfor %} </table> </form> -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.