我使用self.fields来获取所有用户的全名而不仅仅是用户名,现在我想添加一个空字段作为第一选择......
目前
def __init__(self, user, *args, **kwargs):
super(TrophiesForm, self).__init__(*args, **kwargs)
self.fields['outfitter'].choices = [(user.pk, user.get_full_name()) for user in users]
答案 0 :(得分:2)
self.fields['outfitter'].choices = [('', '')] + [(user.pk, user.get_full_name()) for user in users]