I'm using IntegerChoices
in my Django (3.2) model.
class AType(db.IntegerChoices):
UNKNOWN = 0, 'Unknown'
SOMETHING = 1, 'Something'
ANOTHER_THING = 2, 'Another thing'
A_THIRD_THING = 3, 'A third thing'
class MyObject(models.Model):
a_type = db.IntegerField(choices=AType.choices)
(I've changed the choices to be more generic.)
Every time I add a value to AType, it produces a DB migration, which I faithfully apply.
a_type
is strictly behind the scenes. Users never see it, so it's only in the admin UI, but I don't need it to be editable. So forms aren't really used.
Is there any impact on the DB (e.g., constraints) of these migrations?
Is there any other utility to having an IntegerChoices field, given that it's not displayed to a (non-staff) user, and not in a form?
If there's no utility, I'm thinking of just changing MyObject.a_type
to an IntegerField, and continuing to use AType
everywhere, but not having all the migrations.