I have a class that inherits from models.IntegerChoices
and defines certain constants I use in my model. I want to make the "labels" of my integer choices a variable in the settings.py
:
class Status(models.IntegerChoices):
ONE = 0, settings.ONE_LABEL
TWO = 1, settings.TWO_LABEL
When playing around with this I found that whenever I change ONE_LABEL
or TWO_LABEL
in my settings, Django would like to create a new migration similar to
migrations.AlterField(
model_name='mymodel',
name='status',
field=models.IntegerField(choices=[(0, 'New one label'), (1, 'New two label')], default=0),
)
My goal is to deploy multiple (very similar) servers where only UI elements (that display the names of status
) change according to the values in my settings
.
I guess it is not wise to allow changes in my settings to trigger any changes in the database, as that would make updating later versions of my project much harder. Is it safe to ignore the possible migration?
I thought the way above is the easiest as I have multiple model forms and other components that use the label of my status class. This would allow a single change in my settings to be transferred throughout my project. I can't see why changing the label would require a DB migration as long as I don't change the values. I wonder if there is any better way to achieve the same goal.