[Fixed]-Pass a blank object to a self instance model

1๐Ÿ‘

โœ…

I hope Iโ€™m getting this right, but Iโ€™m guessing that even with the empty_label set to None you are still seeing the first category in the list selected.

When you override a ModelForm field, like you do now for category_parent, you lose the automatically connected required=False form correspondent for the blank=True in the model.

Try adding required=False to the form field, like this:

category_parent = forms.ModelChoiceField(queryset=Category.objects.all(), empty_label='None', required=False)
๐Ÿ‘คAndrei Avram

Leave a comment