Re: Newbie: Accessor and Definition help

2007-02-25 Thread DuncanM

Indeed, I am such an idiot at times.

Once again your help is very much appreciated.
Many thanks
Duncan

On Feb 26, 1:06 am, "Chase" <[EMAIL PROTECTED]> wrote:
> I don't know exactly what it's referring to, but check to make sure
> that any True's in your model (I don't see any in the one you posted)
> are spelled "True" and not "TRUE".  Python is case sensitive.
>
> > $ python2.4 manage.py syncdb
> > Error: Couldn't install apps, because there were errors in one or more
> > models:
> > htafc.teams: name 'TRUE' is not defined
>
> > What is this referring too please?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Newbie: Accessor and Definition help

2007-02-25 Thread Chase

I don't know exactly what it's referring to, but check to make sure
that any True's in your model (I don't see any in the one you posted)
are spelled "True" and not "TRUE".  Python is case sensitive.

> $ python2.4 manage.py syncdb
> Error: Couldn't install apps, because there were errors in one or more
> models:
> htafc.teams: name 'TRUE' is not defined
>
> What is this referring too please?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Newbie: Accessor and Definition help

2007-02-25 Thread DuncanM

Thank you Honza and Chase, you have both been extremely helpful.

Many thanks,
Duncan

On Feb 26, 12:09 am, "Chase" <[EMAIL PROTECTED]> wrote:
> More like:>   goalkeeper = models.ForeignKey(Player, 
> related_name="goalkeeper_for")
> >   leftback = models.ForeignKey(Player, related_name="leftback_for")
>
> etc.
>
> What ForeignKey does is creates a reference in the object related
> (Player) so that you could also analyze the relationship in reverse
> (i.e., say Player.goalkeeper_for to find out which games given Player
> was goalkeeper for).  By default, the related_name is always
> "result_set". Anytime you have more than one ForeignKey referencing
> the same model from a given model, you must give each a unique
> related_name so they don't clash.
>
> Best regards,
> Chase


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Newbie: Accessor and Definition help

2007-02-25 Thread Chase

More like:
>   goalkeeper = models.ForeignKey(Player, related_name="goalkeeper_for")
>   leftback = models.ForeignKey(Player, related_name="leftback_for")
etc.

What ForeignKey does is creates a reference in the object related
(Player) so that you could also analyze the relationship in reverse
(i.e., say Player.goalkeeper_for to find out which games given Player
was goalkeeper for).  By default, the related_name is always
"result_set". Anytime you have more than one ForeignKey referencing
the same model from a given model, you must give each a unique
related_name so they don't clash.

Best regards,
Chase


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Newbie: Accessor and Definition help

2007-02-25 Thread DuncanM

as in:
  goalkeeper = models.ForeignKey(Player, UNIQUE)
  leftback = models.ForeignKey(Player, UNIQUE)
  centreback1 = models.ForeignKey(Player, UNIQUE)
  centreback2 = models.ForeignKey(Player, UNIQUE)
  rightback = models.ForeignKey(Player, UNIQUE)
  leftmid = models.ForeignKey(Player, UNIQUE)

etc??

On Feb 25, 10:29 pm, "Honza Král" <[EMAIL PROTECTED]> wrote:
> On 2/25/07, DuncanM <[EMAIL PROTECTED]> wrote:
>
>
>
> > 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?
>
> your modeling is fine, just add UNIQUE related_name to each foreign
> key so that they don't crash...
>
> if you keep it like this, what should you get, when you ask for a
> result_set on a player object?
> all the results where he played as goalkeeper or striker?
>
> the system doesn't know and it needs you to sort this out
>
>
>
>
>
> > 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
>
> --
> Honza Kr?l
> E-Mail: [EMAIL PROTECTED]
> ICQ#:   107471613
> Phone:  +420 606 678585


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Newbie: Accessor and Definition help

2007-02-25 Thread Honza Král
On 2/25/07, DuncanM <[EMAIL PROTECTED]> wrote:
>
> 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?
your modeling is fine, just add UNIQUE related_name to each foreign
key so that they don't crash...

if you keep it like this, what should you get, when you ask for a
result_set on a player object?
all the results where he played as goalkeeper or striker?

the system doesn't know and it needs you to sort this out

>
> 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
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---