This is my first post on stackoverflow, I will try to follow the basic rules, but be careful with me.
I need to make a few changes (which looked superficial at first glance) in a django application. The client wants all the drop-down menus of the forms in the admin part of the site to be sorted in alphabetical order. The problem is that some of these options are based on static lists defined in models.py files, such as:
STATE=( (1, 'Full'), (2, 'Damaged'), (3, 'Partially damaged') )
I tried to reorder the list:
STATE=( (2, 'Damaged'), (1, 'Full'), (3, 'Partially damaged') )
but it doesn't seem to make any difference (although I'm not very good at how Python caches classes and views).
Reordering such indexes:
STATE=( (1, 'Damaged'), (2, 'Full'), (3, 'Partially damaged') )
works, but it will mean writing huge and complex SQL scripts to keep old data consistent (since most lists are longer than this, and permutations become more complex).
So my question is: is there a way to sort these options based on their name instead of index? Perhaps in the definition of models.IntegerField(..., choices=STATE) ?
Thanks to everyone.