admin.ModelAdmin 后台管理关联对象,某个字段如何显示值?
对象 WxpAccount: accountName = 。。。对象 AccountMenu: wxpAccount = models.ForeignKey(WxpAccount,null=True)class AccountMenuAdmin(admin.ModelAdmin): list_select_related = True list_display = ('name','type','key','wxpAccount__accountName')#列表显示admin.site.register(wxm.AccountMenu,AccountMenuAdmin)为什么 在admin管理页面,wxpAccount.accountName 显示不出来? 报错误。------解决方案--------------------class AccountMenuAdmin(admin.ModelAdmin): def account_name(self,obj): return obj.wxpAccount.accountName account_name.short_description = u'记录名称' list_display = ('name','type','key','account_name')