mfogel / django-timezone-field

A Django app providing DB, form, and REST framework fields for zoneinfo and pytz timezone objects.
BSD 2-Clause "Simplified" License
397 stars 95 forks source link

sorting list of timezones on ModelForm? #116

Closed ccurvey closed 6 months ago

ccurvey commented 11 months ago

I can't be the first person to ask this...I feel like I'm having a brain cramp.

class Profile(models.Model):
    timezone = TimeZoneField(default="America/New_York")

class ProfileForm(forms.ModelForm):
    class Meta:
        model = Profile
        fields = ['timezone']

I get the list of timezones in a nice drop-down when I show my form, but they're in a random(?) order. How can I get them sorted?

webtweakers commented 10 months ago

Same issue here.

Mind you, as in the examples, I have something like this in my ModelForm:

tz = TimeZoneFormField(choices_display="WITH_GMT_OFFSET")

The time zones are sorted by GMT from GMT-12:00 to GMT+14:00. But there are many, for example, there is over a page of GMT+01:00 in the drop down, and the Region/City shown next to the GMT offset are all in random order.