Ooops I realise you can use a verbose name on a foreign key field you
must just use verbose_name="xxx"
e.g. Poll = models.ForeignKey(Poll, verbose_name="the related poll")

On Mar 5, 9:16 am, "DuncanM" <[EMAIL PROTECTED]> wrote:
> Thank you Kai,
> I really appreciate the time you put in to help me with that, it had
> me puzzled because all this time I was looking for something wrong
> with my fixture or result classes when it fact it had nothing to do
> with them, it was due to my last class called SquadSelector as shown
> below:
>
> class SquadSelector(models.Model):
>   fixture = models.ForeignKey(Fixture, "Fixture", core=True,
> help_text="Fixture to select squad for.")
>   gk = models.ForeignKey(Player, "Goal Keeper", related_name="gk",
> core=True, help_text="Name of Goal Keeper.")
>   rb = models.ForeignKey(Player, "Right Back", related_name="rb",
> core=True, help_text="Name of Right Back.")
>   cb1 = models.ForeignKey(Player, "Centre Back", related_name="cb1",
> core=True, help_text="Name of First Centre Back.")
>   cb2 = models.ForeignKey(Player, "Centre Back", related_name="cb2",
> core=True, help_text="Name of Second Centre Back.")
>   lb = models.ForeignKey(Player, "Left Back", related_name="lb",
> core=True, help_text="Name of Left Back.")
>   rw = models.ForeignKey(Player, "Right Wing", related_name="rw",
> core=True, help_text="Name of Right Winger.")
>   cm1 = models.ForeignKey(Player, "Centre Midfield",
> related_name="cm1", core=True, help_text="Name of First Centre
> Midfielder.")
>   cm2 = models.ForeignKey(Player, "Centre Midfield",
> related_name="cm2", core=True, help_text="Name of Second Centre
> Midfielder.")
>   lw = models.ForeignKey(Player, "Left Wing", related_name="lw",
> core=True, help_text="Name of Left Winger.")
>   cf1 = models.ForeignKey(Player, "Centre Forward",
> related_name="cf1", core=True, help_text="Name of First Centre
> Forward.")
>   cf2 = models.ForeignKey(Player, "Left Forward", related_name="cf2",
> core=True, help_text="Name of Second Centre Forward.")
>   sub1 = models.ForeignKey(Player, "1st Sub", related_name="sub1",
> help_text="Name of 1st Sub.")
>   sub2 = models.ForeignKey(Player, "2nd Sub", related_name="sub2",
> help_text="Name of 2nd Sub.")
>   sub3 = models.ForeignKey(Player, "3rd Sub", related_name="sub3",
> help_text="Name of 3rd Sub.")
>   sub4 = models.ForeignKey(Player, "4th Sub", related_name="sub4",
> help_text="Name of 4th Sub.")
>   sub5 = models.ForeignKey(Player, "5th Sub", related_name="sub5",
> help_text="Name of 5th Sub.")
>   class Admin:
>     pass
>     list_display = ('fixture', )
>     list_filter = ['fixture',]
>     search_fields = ['fixture']
>
>   # --------
>   # Accessor
>   # --------
>
>   #String method
>   def __str__ (self):
>     return str(self.gk)
>
> >From the line:
>
>   fixture = models.ForeignKey(Fixture, "Fixture", core=True,
> help_text="Fixture to select squad for.")
> the bit "Fixture" which I have on all my fields because I thought it
> is a verbose name, which you cannot apparantly specify for a foreign
> key (I assume it gets it from the other table?) So it was looking for
> a field called Fixture in the table Fixture, which there was not and
> giving me the error:
>
>     raise FieldDoesNotExist, '%s has no field named %r' %
> (self.object_name, name)
> django.db.models.fields.FieldDoesNotExist: Fixture has no field named
> 'Fixture'
> Which made me look at my fixture class when indeed it wasn't the place
> the error was occuring.
>
> Thanks again,
> DuncanM
> On Mar 5, 12:07 am, "Kai Kuehne" <[EMAIL PROTECTED]> wrote:
>
> > Hi Duncan,
>
> > this works for me:
>
> > from django.db import models
>
> > class Fixture(models.Model):
> >     #team = models.ForeignKey(Team, "Team", core=True)
> >     #venue = models.CharField("Venue", maxlength=1,
> > choices=Fixture_Choices, core=True)
> >     date = models.DateField("Date", core=True)
> >     opponent = models.CharField("Opponent", maxlength=100, core=True)
> >     kickoff = models.TimeField("Kick Off Time")
> >     #competition = models.ForeignKey(Competition, "Competition", core=True)
>
> >     class Admin:
> >         #list_display = ('date', 'team', 'opponent', 'venue',
> > 'kickoff', 'competition')
> >         #list_filter = ['date', 'team', 'competition']
> >         list_display = ('date', 'opponent', 'kickoff')
> >         list_filter = ['date']
> >         search_fields = ['date']
>
> > class Result(models.Model):
> >     fixture = models.OneToOneField(Fixture, core=True)
> >     howdenscore = models.IntegerField("Howden Score", core=True)
> >     opponentscore = models.IntegerField("Opponent Score", core=True)
>
> >     class Admin:
> >         list_display = ('howdenscore', 'opponentscore',)
> >         list_filter = ['howdenscore',]
> >         search_fields = ['howdenscore']
>
> > I removed the help text and commented out what you didn't get us. :)
>
> > Kai


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