开发者

Django add empty field on forms

I have used self.fields to get all the users full names instead of just user names, no开发者_Go百科w I would like to just add an empty field as the first choice...

Currently.

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]


self.fields['outfitter'].choices = [('', '')] + [(user.pk, user.get_full_name()) for user in users]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜