I have 2 classes:

class Player(models.Model):
  team = models.ForeignKey(Team)
  forename = models.CharField(maxlength=50)
  surname = models.CharField(maxlength=50)
  age = models.PositiveIntegerField()
  sex = models.CharField(maxlength=1, choices=Gender_Choices)
  class Admin:
    pass
    list_display = ('forename', 'surname', 'age', 'team', 'sex')
    list_filter = ['team']
    search_fields = ['forename']
  #String method
  def __str__(self):
    return self.surname

and

class Result(models.Model):
  team = models.ForeignKey(Team)
  venue = models.CharField(maxlength=1, choices=Fixture_Choices)
  date = models.DateField()
  opponent = models.CharField(maxlength=100)
  competition = models.ForeignKey(Competition)
  howdenscore = models.IntegerField()
  opponentscore = models.IntegerField()
  goalkeeper = models.ForeignKey(Player)
  leftback = models.ForeignKey(Player)
  centreback1 = models.ForeignKey(Player)
  centreback2 = models.ForeignKey(Player)
  rightback = models.ForeignKey(Player)
  leftmid = models.ForeignKey(Player)
  centremid1 = models.ForeignKey(Player)
  centremid2 = models.ForeignKey(Player)
  rightmid = models.ForeignKey(Player)
  striker = models.ForeignKey(Player)
  striker = models.ForeignKey(Player)
  sub1 = models.ForeignKey(Player)
  sub2 = models.ForeignKey(Player)
  sub3 = models.ForeignKey(Player)
  sub4 = models.ForeignKey(Player)
  sub5 = models.ForeignKey(Player)
  class Admin:
    pass
    list_display = ('date', 'team', 'venue', 'opponent',
'competition', 'howdenscore', 'opponentscore')
    list_filter = ['date', 'team', 'venue', 'competition']
    search_fields = ['date']
  def __str__ (self):
    return self.opponent


However when I try and run syncdb I get the following error:
teams.result: Accessor for field 'sub5' clashes with related field
'Player.result_set'. Add a related_name argument to the definition for
'sub5'.

teams.result: Accessor for field 'sub5' clashes with related field
'Player.result_set'. Add a related_name argument to the definition for
'sub5'.


*Note that I get the same error for each of the fields from goalkeeper
through to sub5 (all are foreignkeys of player)


Am I going about it in the right way?  Or is my modelling wrong?

What I'm trying to achieve is having a table full of players, and for
a result I want to see which 17 of those players were at the game (to
calculate appearances later on) so the results page would be such
like:

Team A vs Team B
10th March
Old Trafford
2-1
Gary Neville
Edwin Van der Saar
Patrice Evra
Rio Ferdinand
Wayne Rooney

etc (listing the full team who played and the subs chosen)

Many thanks,
Duncan


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to