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.
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
> I can put a test case together if you like.
Yes, please. Or a sample project that we can just run to play with.
(Pending that I'll assume it reproduces. 🙂)
I need to look deeper to see exactly what's going on here, but there's at
least a documentation issue:
> An iterable (e.g., a list or tuple) ...
If it's **required** to be ordered it should say `sequence` or similar.
I'd suspect it's just been assumed that a list or tuple would be used.
Maybe we can relax that. If not we'll have to change the docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/30505#comment:1>
* cc: Carlton Gibson (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/30505#comment:2>
* Attachment "ticket30505.tar.bz2" added.
Test case. Running makemigrations will create new migrations indefinitely
* status: new => assigned
* owner: nobody => Caio Ariede
--
Ticket URL: <https://code.djangoproject.com/ticket/30505#comment:3>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/11421 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/30505#comment:4>
* has_patch: 1 => 0
* type: Bug => Cleanup/optimization
Comment:
This should be clarified in documentation, maybe "{{{A
:term:`sequence`}}}" instead of "{{{An iterable ...}}}" or a note about
ordering.
--
Ticket URL: <https://code.djangoproject.com/ticket/30505#comment:5>
* has_patch: 0 => 1
Comment:
new [https://github.com/django/django/pull/11429 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/30505#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"5248abe9b0425c1fc989c60a55860cdb4d135bcf" 5248abe9]:
{{{
#!CommitTicketReference repository=""
revision="5248abe9b0425c1fc989c60a55860cdb4d135bcf"
Fixed #30505 -- Doc'd how changes in the order of Field.choices affect
migrations.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30505#comment:7>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"d6d65c1e87d0da52e43d6359290a7b3f77367576" d6d65c1]:
{{{
#!CommitTicketReference repository=""
revision="d6d65c1e87d0da52e43d6359290a7b3f77367576"
[2.2.x] Fixed #30505 -- Doc'd how changes in the order of Field.choices
affect migrations.
Backport of 5248abe9b0425c1fc989c60a55860cdb4d135bcf from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30505#comment:8>