On Thu, Nov 20, 2008 at 10:15 AM, JimR <[EMAIL PROTECTED]> wrote:

>
> Karen,
>
> Thanks for your help.  Here's what I've done:
>
> I've commented out the list_display for GameAdmin and defined a
> __unicode__ for game as:
>
>        def __unicode__(self):
>                return '%s vs. %s' %  (self.team.name, self.opponent)
>
> That returns values in the admin display as "Team 1 vs. Team 2", etc.,
> as we would have hoped.
>
> Uncommenting the list_display as so:
> class GameAdmin(admin.ModelAdmin):
>        list_display = ('team', 'opponent',)
>         search_fields = ('team__name','opponent',)
>
> results in the strange behavior (non-zero count but showing no rows)
>
> changing list display to team__name results in the following error:
> 'team__name' is not a callable or an attribute of 'GameAdmin' or found
> in the model 'Game'.
>
> So now that I copied that and pasted that error message here, I have a
> thought: make a callable for Game as:
>        def _team_name(self):
>             return (self.team.name)
>        team_name = property(_team_name)
>
> class GameAdmin(admin.ModelAdmin):
>        list_display = ('team_name', 'opponent',)
>        search_fields = ('team__name','opponent',)
>
> Everything now displays correctly.  Reading the documentation on
> list_display and Abstract classes, I assumed that I could reference
> Team elements through the AbstractEvent model.  Apparently, that is
> not the case. The callable seems to have solved my problem.
>

I am glad you found something that works, but this should not have been
necessary.  As I said earlier, cut-and-pasting the models & admin def you
posted into a new project (commenting out all the foreign keys in Team
pointing to models not provided) on one of my machines gives an admin that
properly displays the team and opponent in the change list.  So, there's
something not quite right in your other code or possibly the data in your
DB, though I have no clue what since I've never heard this symptom reported
before.

It will probably be best for you to figure out what it is sooner rather than
later -- I'd be surprised if whatever it is doesn't cause other weird
problems down the road.  I'd start with what you posted, in a new project
with a test sqlite db that can be reset at will, adding things from your
real project bit by bit until you see what it is, exactly, that is causing
this.  It is really not normal or expected behavior.

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