Answer the question
In order to leave comments, you need to log in
Why in django 1.9 do I get migrations when I makemigrations that I don't expect?
in the model i have a field
currency = models.CharField(_('currency'), choices=[(x, x) for x in settings.CURRENCIES], max_length=3)
....
migrations.AlterField(
model_name='mymodel',
name='currency',
field=models.CharField(choices=[('USD', 'USD'), ('JPY', 'JPY')], max_length=3, verbose_name='currency'),
),
.....
Answer the question
In order to leave comments, you need to log in
These are internal migrations - django. Users, Groups, Permissions
The value of the c field choices
is formed statically at the migration stage. It's just that at this moment your list comprehension is interpreted, a list is formed and the field is updated with it. The fact that nothing has changed since the last time during the migration is not tracked.
If you do not want to see this migration every time - set the list of currencies statically, by hand.
If it is supposed to change "on the fly" - improve the connection with the currency reference (via ForeignKey
or ManyToManyField
)
Well, or each time correct the migration before applying it, deleting this field.
Or delete this migration if changing this field in it is the only operation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question