1👍
✅
Since this is a CharField
, the keys should be strings, so '0'
, not 0
:
OBJECT_TYPES = (
('0', "analog-input"),
('1', "analog-output"),
('2', "analog-value")
)
an alternative is to work with an IntegerField
:
OBJECT_TYPES = (
(0, "analog-input"),
(1, "analog-output"),
(2, "analog-value")
)
class MyModel(models.Model):
object_type = models.IntegerField(
choices=OBJECT_TYPES,
blank=True,
null=True
)
Source:stackexchange.com