I have a model like this
class Product(models.Model):
class Maca(models.IntegerChoices):
Yes = 1,
No = 2,
maca = models.PositiveSmallIntegerField(
db_column='maca', choices=Maca.choices
)
and a form like this
class ProductForm(forms.ModelForm):
maca = forms.ChoiceField(required=False, choices=Product.Maca.choices, widget=forms.RadioSelect())
I have one case that this field will not show on the form.
But when it is not in the form, the field 'maca' will submitted as '' (Blankn) and I'm getting an error for this
ValueError: Field 'maca' expected a number but got ''.
Can someone help me please? How can I send this in database as None value?