Karen,

Thanks for the quick response, and sorry, I do have quotes around
them, I just mistyped when I added them back in for the purposes of
this post.

Here's the abbreviated Team model, and the corrected Admin Manager.
We do not have a __unicode__ method defined for the Team model.

I've reposted everything for easier reading.

class Team(models.Model):
        name = models.CharField(max_length=50)
        org = models.ForeignKey(Organization, related_name='teams')
        level = models.CharField(choices=COMPETITIVE_LEVEL, max_length=20)
        activity = models.ForeignKey(ActivityDetail)
        headcoach = models.ForeignKey(Coach, related_name='teams',
blank=True, null=True)
        coaches = models.ManyToManyField(Coach, blank=True, null=True)
        season = models.ForeignKey(Season, related_name='teams')
        is_archive = models.BooleanField(default=False)
        division = models.ForeignKey(Division, related_name='teams)
       ...

class AbstractEvent(models.Model):
        team = models.ForeignKey(Team)
        description = models.TextField(null=True, blank=True)
        description_rendered = models.TextField(null=True, blank=True)
        when = models.DateTimeField()
        where = models.ForeignKey(Address)
        created_at = models.DateTimeField(default=datetime.today)
        created_by = models.ForeignKey(User)
       ...
        class Meta:
                abstract = True

class Game(AbstractEvent):
        opponent = models.CharField(max_length=128)
        minutes_early = models.PositiveIntegerField(null=True,
blank=True)
        counts_towards_record = models.BooleanField(default=True)
        points_for = models.IntegerField(null=True, blank=True)
        points_against = models.IntegerField(null=True, blank=True)
        ...

The AdminManager for the Game model is as follows:

class GameAdmin(admin.ModelAdmin):
        list_display = ('team', 'opponent',)
        search_fields = ('team', 'opponent',)
      ...



On Nov 19, 6:19 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 5:13 PM, JimR <[EMAIL PROTECTED]> wrote:
>
> > We have defined the following models:
>
> > class AbstractEvent(models.Model):
> >        team = models.ForeignKey(Team)
> >        description = models.TextField(null=True, blank=True)
> >        description_rendered = models.TextField(null=True, blank=True)
> >        when = models.DateTimeField()
> >        where = models.ForeignKey(Address)
> >        created_at = models.DateTimeField(default=datetime.today)
> >        created_by = models.ForeignKey(User)
> >       ...
> >        class Meta:
> >                abstract = True
>
> > class Game(AbstractEvent):
> >        opponent = models.CharField(max_length=128)
> >        minutes_early = models.PositiveIntegerField(null=True, blank=True)
> >        counts_towards_record = models.BooleanField(default=True)
> >        points_for = models.IntegerField(null=True, blank=True)
> >        points_against = models.IntegerField(null=True, blank=True)
> >        ...
>
> > The AdminManager for the Game model is as follows:
>
> > class GameAdmin(admin.ModelAdmin):
> >        list_display = (team, 'opponent',)
> >        search_fields = (team, 'opponent',)
>
> > The problem is that including 'team' in the list_display causes the
> > admin to not list any games, but recognizes that there are games in
> > the table since it gives a total games count.  If I remove 'team," the
> > admin interface displays a list of games displaying "opponent."
>
> > Any help or suggestions are greatly appreciated!
>
> Do you really not have quotes around team?  That will make the admin treat
> it as a callable, not a model field, for list_admin (and I don't believe
> callables are supported in search_fields so there's a problem).  Unless you
> have a callable team defined in your admin.py I'd expect what you show to
> generate a NameError.  If you do have quotes around team, I'd be interested
> in seeing your Team model and especially it's __unicode__ method.
>
> Karen
--~--~---------~--~----~------------~-------~--~----~
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