django:admin.StackedInline显示全名而不是用户名
我的内联:
class CollaboratorInLine(admin.StackedInline):
model = Collaborator
extra = 0
我的模型:
class Collaborator(models.Model):
report = models.ForeignKey(Report)
collaborator = models.ForeignKey(User, limit_choices_to={'groups__name':u'team1'})
def reutnName(self):
return self.collaborator.get_full_name()
def __unicode__(self):
return self.collaborator.get_full_name()
内联协作者显示为下拉列表,并且 ppl 显示为用户名而不是全名。 有谁知道如何将其更改为全名吗?
谢谢
my inline:
class CollaboratorInLine(admin.StackedInline):
model = Collaborator
extra = 0
my model:
class Collaborator(models.Model):
report = models.ForeignKey(Report)
collaborator = models.ForeignKey(User, limit_choices_to={'groups__name':u'team1'})
def reutnName(self):
return self.collaborator.get_full_name()
def __unicode__(self):
return self.collaborator.get_full_name()
The inline collaborator is shown as a drop downlist, and the ppl are shown as usernames intead of full names.
does anyone know how to change it to full name?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 formfield_for_manytomany 和 formfield_for_foreignkey 得到它
我以为它们只能在 modeladmin 中使用,但它也可以用于 StackedInline
:)
i got it using formfield_for_manytomany and formfield_for_foreignkey
i thought they could only be used in modeladmin, but it could also be used for StackedInline
:)