开发者

django: admin.StackedInline show full name instead of user name

开发者 https://www.devze.com 2023-01-12 12:29 出处:网络
my inline: class CollaboratorInLine(admin.StackedInline): model = Collaborator extra = 0 my model: class Collaborator(models.Model):

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开发者_StackOverflow?

thanks


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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消