Alex Rivera | Logout

Django: Country drop down list?

Asked 2010-06-03T07:10:55.693
25

I have a form for address information. One of the fields is for the address country. Currently this is just a textbox. I would like a drop down list (of ISO 3166 countries) for this. I'm a django newbie so I haven't even used a Django Select widget yet. What is a good way to do this?

Hard-code the choices in a file somewhere? Put them in the database? In the template?

Edit
Report

2 Answers

37

Check out "choices" parameter of a CharField.

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

answered 2010-06-03T07:37:42.540
8

Django Countries

from django_countries.countries import COUNTRIES

class CountryForm(forms.Form):
      country= forms.ChoiceField(COUNTRIES)
answered 2010-08-28T21:54:37.903

Your Answer