Closed eriktelepovsky closed 6 years ago
It should be, through the SortedSelect widget. It lazily sorts, so it works properly with different translations. Is your form using that widget?
Yes, I already tried to use:
widget=SortedSelect()
and it worked for a while. Then I updated to Django 1.11.7 and it stopped working. Also, default model fields in the admin do not have sorted country choices:
That's a shame. I'll look into it.
I checked and it should work since commit:9677b8053b090ab5eb91fce31e9eaa8ba880c815. That commit hasn't made it into a release yet. Could you verify the current master fixes the issue?
Yes, I confirm. Works fine in the current master ;) Thank you.
I would like to reopen this issue:
country = forms.ChoiceField(label=_('Country'), choices=[('', _('Choose a country'))] + list(get_countries_lazy()))
it is sorted by keys, not values:
Hi. The choices of CountryFormField are not sorted. Is it a purpose?
Right now, I have to use choices argument to fix that like this:
It would be great if the choices are sorted by country name by default.