-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new country list format for fields
- Loading branch information
1 parent
5876afb
commit 45a79c2
Showing
3 changed files
with
48 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
from django_countries.fields import CountryField | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django_countries.countries import COUNTRIES | ||
from django_countries.conf import settings | ||
|
||
|
||
def country_list(): | ||
""" | ||
Return a list of countries, sorted by name. | ||
Each country record consists of a tuple of the short name and two letter | ||
ISO3166-1 country code. | ||
""" | ||
country_list = [] | ||
overrides = settings.COUNTRIES_NAME_OVERRIDES | ||
for code, name in COUNTRIES(name, code): | ||
if code in overrides: | ||
name = overrides['code'] | ||
if name: | ||
country_list.append((name, code)) | ||
return sorted(country_list) |