Customization

Customize the country list

Country names are taken from the official ISO 3166-1 list. If your project
requires the use of alternative names, the inclusion or exclusion of specific
countries then use the COUNTRIES_OVERRIDE setting.

A dictionary of names to override the defaults.

Note that you will need to handle translation of customised country names.

Setting a country’s name to None will exclude it from the country list.
For example:

COUNTRIES_OVERRIDE = {
'NZ': _('Middle Earth'),
'AU': None
}

If you have a specific list of countries that should be used, use
COUNTRIES_ONLY:

COUNTRIES_ONLY = {
'NZ': _('Middle Earth'),
'AU': _('Desert'),
}

Show certain countries first

Provide a list of country codes as the COUNTRIES_FIRST setting and they
will be shown first in the countries list (in the order specified) before all
the alphanumerically sorted countries.

By default, these ‘first’ countries are not repeated again in the
alphanumerically sorted list. If you would like them to be repeated, set the
COUNTRIES_FIRST_REPEAT setting to True.

Finally, you can optionally separate these ‘first’ countries with an empty
choice by providing the choice label as the COUNTRIES_FIRST_BREAK setting.

Customize the flag URL

The COUNTRIES_FLAG_URL setting can be used to set the url for the flag
image assets. It defaults to:

COUNTRIES_FLAG_URL = 'flags/{code}.gif'

The URL can be relative to the STATIC_URL setting, or an absolute URL.

The location is parsed using Python’s string formatting and is passed the
following arguments:

code

code_upper

For example: COUNTRIES_FLAG_URL = 'flags/16x10/{code_upper}.png'

No checking is done to ensure that a static flag actually exists.

Alternatively, you can specify a different URL on a specific CountryField: