Django: Country drop down list?

Django Countries

from django_countries.fields import CountryField

class Foo(models.Model):
    country = CountryField()

Ended up using the below snippet which basically defines a tuple of tuples of two character country codes. Additionally it defines a custom field type called CountryField and defaults the choices parameter to the above defined tuple. This automatically gets rendered as a drop down list.

http://djangosnippets.org/snippets/494/


Check out "choices" parameter of a CharField.

You might also want to take a look at django-countries.


Django Countries

from django_countries.countries import COUNTRIES

class CountryForm(forms.Form):
      country= forms.ChoiceField(COUNTRIES)