class Maca(models.Model):
class Maca2(models.IntegerChoices):
Personal = 1,
Work = 2,
Transport = 3,
__empty__ = _('Select')
maca2 = models.PositiveSmallIntegerField(
db_column='Maca2', choices=Maca2.choices, null=True, blank=True
)
When I submit as empty value I got the following error
Field 'maca2' expected a number but got 'Select'.
CodePudding user response:
You should use CharField instead of PositiveSmallIntegerField, check it here:
maca2 = models.CharField(
db_column='Maca2', choices=Maca2.choices, null=True, blank=True )