ApPeL
ApPeL

Reputation: 4921

Django add empty field on forms

I have used self.fields to get all the users full names instead of just user names, now 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]

Upvotes: 0

Views: 172

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 600059

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

Upvotes: 2

Related Questions