1👍
✅
This is likely because you use TextChoices
subclass, you probably should use an IntegerChoices
object:
class Cat(models.Model):
class Sex(models.IntegerChoices):
M = 1, 'Male'
F = 2, 'Female'
sex = models.PositiveSmallIntegerField(
choices=Sex.choices, blank=False, null=False
)
The choices will have as difference that the choices for a TextChoices
are '1'
and '2'
, so strings, whereas for IntegerChoices
, these are 1
and 2
, so integers.
Source:stackexchange.com