There's quite a lot wrong with this code, quite apart from the list_display issue. Comments interspersed below.
On Aug 19, 2:33 pm, saeb <[EMAIL PROTECTED]> wrote: > No, that is not the real code. The real code as you mentioned is split > into models.py and admin.py. And I am referring to the functions as > strings ( a typo on my part). After posting the message last night I > messed with the code more and function is displaying as 'none' . > Referring to Malcolm's last suggestion, I changed the function to > return an attribute and I still see the same issue, where the column > is 'none' in display. > > This is what I have. I really appreciate your help > > ---models.py---- > > class privateAcctManager(models.Manager): > def show_acct_name(self): > t = Acct.objects.all().filter(id= self.id).name > return t You can't do this. The result of filter() is always a queryset, even if only one object is returned. Plus 'self' here refers to the manager, which doesn't have an ID. Anyway, this code doesn't really belong in a manager, but in a method on the model itself. > class privateAcct(models.Model): > id = models.ForeignKey(Acct) > obj = privateAcctManager() > > def acct_name(self): > return self.obj.show_acct_name() No need for the reference to the manager here. Just return self.id.name. id is a really bad name for the foreign key to Acct (which doesn't seem to exist in the code you've got here - or did you mean Account?) This will clobber the autogenerated primary key. If you want an actual foreign key as primary key, you should probably be using OneToOneField instead. > class Meta: > db_table= 'private_acct' > > class PublicAcct(models.Model): > id = models.ForeignKey(Acct) > class Meta: > db_table= 'public_acct' Same comments apply re use of id here. > class Account(models.Model): > name = models.TextField() > balance = models.decimalfield() > > -------admin.py-------- > > class PrivateAcctAdmin(admin.modelAdmin): > list_display =( 'id', 'acct_name' ) With the changes above, this should now work (assuming it's indented properly). -- DR. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---