开发者

Django add empty field on forms

开发者 https://www.devze.com 2023-01-24 03:41 出处:网络
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...

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

精彩评论

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