#30505: Ordering of Field.choices is significant for makemigrations
--------------------------------------------+------------------------
Reporter: Marnanel Thurman | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
makemigrations regards the ordering of Field.choices as significant. The
docs require Field.choices to be an iterable, but not to be well-ordered.
If Field.choices is not well-ordered, then almost every run of
makemigrations will treat the model as changed, even without changes to
the code.
The ordering of Field.choices is not significant anywhere else, except as
a cosmetic detail in the admin.
This bug even occurs in
{{{
ACTIVITY_TYPES = set(['Create', 'Update', 'Delete'])
[....]
f_type = models.CharField(
max_length=255,
choices=[(x,x) for x in ACTIVITY_TYPES],
)
}}}
I would have expected the value of Field.choices here to be well-ordered
(and sorted) but makemigrations still flags this as changed every time.
I can put a test case together if you like.
--
Ticket URL: <https://code.djangoproject.com/ticket/30505>
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/051.1605e1eaa3f8626552e220bc5ef7debb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.