I have some simple models:

class Committee( models.Model ):
    name = models.CharField( maxlength=200 )
    leader = models.ForeignKey( "Person", null=True,
                                related_name="leader_of", blank=True)
    notes = models.TextField( blank=True )

    def __str__( self ):
        return self.name

    class Meta:
        ordering = ( 'name', )

    class Admin:
        list_display = ( 'name', 'leader', 'notes' )

class Person( models.Model ):
    firstname = models.CharField( maxlength=200, core=True )
    lastname = models.CharField( maxlength=200, core=True )
    email = models.EmailField(core=True)
    phone_number = models.PhoneNumberField(core=True)
    # maybe not everyone will be in a committee:
    committee = models.ForeignKey( Committee,
                                   null = True,
                                   related_name="members")
    notes = models.TextField( core=True, blank=True )

I'd like the admin display of Committees to display the committee
members.  I tried adding 'members.all()' to the Admin list_display,
but that didn't work.  I can sort of do it if I add this function to
the Committee class:

    def all_members_str( self ):
        all_members = ""
        for member in self.members.all():
            all_members += str( member ) + "; \n"
        return all_members
    all_members_str.short_description = "Members"

and then add 'all_members_str' to the list_display, but it doesn't
come out looking that great.  Any ideas?

Bryan

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

Reply via email to