On Wed, Nov 19, 2008 at 9:30 PM, JimR <[EMAIL PROTECTED]> wrote: > > 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',) > ... >
Cut and pasting your models & admin def, commenting out all the ForeignKeys for models not included, and putting them in a project yields an admin change list for Game that shows both the Team (unhelpfully identified as "Team object" in the absence of a __unicode__ method in Team) and opponent. So, there's something else involved here. I'd advise starting with what you've posted here -- since that does display a correct admin, and adding things bit by bit to match the full setup you actually have that is not working, to see what is leading to the problem. I've never seen anything like what you describe (change list giving a non-zero count but showing no rows) so I really have no idea what is causing it for you. You will need to change the 'team' in search_fields to specify the field of Team that you want to search on (such as' team__name'). As you have it an attempt to search will likely produce an exception. 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 -~----------~----~----~----~------~----~------~--~---