ChoiceField default to show no value

Here is the form

image

form

class FishTransferForm(forms.ModelForm):
    alias_name = forms.CharField(disabled=True, label='Fish to Transfer')
    current_sponsor = forms.CharField(disabled=True, label='Current Sponsor')
    new_sponsor = forms.ChoiceField(label='New Sponsor', widget=Select)

    class Meta:
        model = CustomUser
        fields = ('current_sponsor', 'alias_name', 'new_sponsor')

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        current_sponsor = CustomUser.objects.filter(id=self.instance.sponsor).values('alias_name').first()
        new_sponsors = CustomUser.objects.filter(sponsor=self.instance.sponsor, status__gte=3).values('id', 'alias_name')

        self.fields['current_sponsor'].initial = current_sponsor['alias_name']
        self.fields['new_sponsor'].choices = [(sponsor['id'], sponsor['alias_name']) for sponsor in new_sponsors]

This list contains the internal and display values for each option. You can create the list with a first value identified as “no value”.

Not seeing a first value option

There isn’t a “first value” option.

You need to create the two-tuple for a “no value” option, and make it the first element of your list.