How to add drop down list for timezone using python-TZ at user registration page using UserCreationForm class
Question: I want to add a Drop down list showing common timezone using PYtZ package at
the time of user registration page. To register an user i am using
UserCreationForm class. Code as follow:

    
    
    class UserRegisterForm(UserCreationForm):
        email2 = forms.EmailField(label=_("E-mail"))
    
        def clean_email2(self):
            email2 = self.cleaned_data['email2']
            try:
                user = User.objects.get(email=email2)
            except User.DoesNotExist:
                return email2
            raise forms.ValidationError(_("Account with this e-mail address already exists."))
    
        def save(self, commit=True):
            user = super(UserRegisterForm, self).save(commit=False)
            user.email = self.cleaned_data["email2"]
            user.is_active = False
            if commit:
                user.save()
            return user
    

I am getting the list of all common timezone using following command:

    
    
    >>> from pytz import timezone
    >>> import pytz
    >>> print(pytz.common_timezones)
    

it prints: <http://pastebin.com/RHdie16M>

I am also aware of the choices fields but to use that is not a good idea. What
should i do?


Answer: You could use a choicefield as such:

    
    
    timezone = forms.ChoiceField(choices=[(x, x) for x in pytz.common_timezones])
    

