#29521: Infinite migrations without changes on code when Choices are store in a
dictionary
-------------------------------------+-------------------------------------
Reporter: Roberto | Owner: nobody
Fernandez Diaz |
Type: Bug | Status: new
Component: | Version: 2.0
Migrations | Keywords: makemigrations
Severity: Normal | migration choices distionary
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have this code on my model
{{{
class Alcance(models.Model):
# CHOICES
CONCEJO = 'CO'
PROVINCIA = 'PR'
PAIS = 'PA'
ZONA_AFECTADA_OPTIONS = {
(CONCEJO, 'concejo'),
(PROVINCIA, 'provincia'),
(PAIS, 'pais')
}
# DATABASE FIELDS
...
zona_afectada = models.CharField(max_length=2,
choices=ZONA_AFECTADA_OPTIONS, default='CO')
}}}
The problem is that each time I execute the command, manage.py
makemigrations
It always detect a change on this part of the code, generating always a
new migration file
Example :
accounts\migrations\0004_auto_20180610_1356.py
{{{
# Generated by Django 2.0 on 2018-06-10 13:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0003_auto_20180602_2019'),
]
operations = [
migrations.AlterField(
model_name='alcance',
name='zona_afectada',
field=models.CharField(choices=[('PA', 'pais'), ('PR',
'provincia'), ('CO', 'concejo')], default='CO', max_length=2),
),
]
}}}
accounts\migrations\0005_auto_20180624_0126.py
{{{
# Generated by Django 2.0 on 2018-06-23 23:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0004_auto_20180610_1356'),
]
operations = [
migrations.AlterField(
model_name='alcance',
name='zona_afectada',
field=models.CharField(choices=[('CO', 'concejo'), ('PR',
'provincia'), ('PA', 'pais')], default='CO', max_length=2),
),
]
}}}
accounts\migrations\0006_auto_20180624_1205.py
{{{
# Generated by Django 2.0 on 2018-06-24 10:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0005_auto_20180624_0126'),
]
operations = [
migrations.AlterField(
model_name='alcance',
name='zona_afectada',
field=models.CharField(choices=[('PA', 'pais'), ('CO',
'concejo'), ('PR', 'provincia')], default='CO', max_length=2),
),
]
}}}
And so on...
As you can see the problem is due to the order in which the choices
appear, that seems to be order randomly.
This is done without me changing the order of the elements of the
dictionary or anything on the code that I show on the top.
--
Ticket URL: <https://code.djangoproject.com/ticket/29521>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.fa37a5e03c9525305644fa3dea345bbd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.