从django管理员list_display访问,这是一对一表中的值 [英] Access from django admin list_display, a value from a One-To-One table
本文介绍了从django管理员list_display访问,这是一对一表中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出模型的一对一扩展,例如Django User模型:
Given a one-to-one extension a model, such as the Django User model:
class UserProfile(models.Model):
user = models.OneToOneField(User, related_name='profile', unique=True)
avatar = models.ImageField(_('Avatar'))
foo = models.CharField(max_length=100, verbose_name="xxx")
如何在管理员中显示该内容?
How can I display that in the admin?
class UserAdmin(admin.ModelAdmin):
list_display = ('email', 'profile__foo' <--NOT WORKING )
查看全文