Do you have a Person object with pk 'None'?
I think you should use
self.fields['lead'] = forms.ModelChoiceField(queryset = Pepole.objects.filter(poc__in = ('lead','sr.lead')), empty_label="None") self.fields['lead2'] = forms.ModelChoiceField(queryset = Pepole.objects.filter(role__in = ('lead','sr.lead')), empty_label="None")
edit:
Since you are using the modelchoicefield field, I think that all of your options will be either model type or none.
You can "expand" the choice of this type by changing the query that you pass to the constructor for the modlechoice field, for example:
qs = People.objects.filter(poc__in = ('lead','sr.lead')) ext = People.objects.filter(role__in = ('lead', 'sr.lead')) qs = qs | ext self.fields['lead'] = forms.ModelChoiceField(queryset = qs, empty_label='None') or for updating self.fields['lead'].queryset = qs
this question says a little about modelchoicefield and may interest you:
How to filter ForeignKey options in Django ModelForm?
Ding
source share