Skip to main content

django-countries-hdx

This lib adds extra M49 data to django-countries.

It uses hdx-python-country with the default data augmented by more UN data to provide SIDS, LLDC and LDC grouping data

Installation

Install this library using pip:

pip install django-countries-hdx

Usage

It adds extra properties to a Country for the region (id and name), sub-region (id and name), SIDS, LDC and LLDC. It also contains helper methods to retrieve the countries in a region or sub-region.

>>> from django_countries.fields import Country
>>> from django_countries_hdx import get_region_name, countries_by_region, countries_by_subregion
>>> Country('NZ').region
9
>>> Country("NZ").region_name
'Oceania'
>>> Country('NZ').subregion
53
>>> Country("NZ").subregion_name
'Australia and New Zealand'
>>> Country("AF").ldc
True
>>> Country("AF").lldc
True
>>> Country("AI").sids
True
>>> regions.get_region_name(9)
'Oceania'
>>> regions.get_region_name(53)
'Australia and New Zealand'
>>> regions.countries_by_region(9)
['AS',
 'AU',
 'CK',
 # …
 ]
>>> regions.countries_by_subregion(53)
['AU', 'NZ', 'NF']

Development

To contribute to this library, first checkout the code. Then create a new virtual environment:

cd django-countries-hdx
python -m venv .venv
source .venv/bin/activate

Now install the test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Data updates

The data is a static file supplied with the lib. You can use the data/merge.py script to update this data. It combines the standard M49 country data from the hdx-python-country lib with the "LDC", "LLDC" and "SIDS" designations from the M49 data downloaded directly.

Download the latest UN data to data/unsd_methodology.csv and run the script from the data dir. It will read the default hdx data and augment it with the UN data.

The merged result is then saved into the lib where it can be read back into the hdx lib.

Metadata

Release files for django-countries-hdx 3.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-countries-hdx 3.0.2
File Size Uploaded
django_countries_hdx-3.0.2.tar.gz 38.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-countries-hdx 3.0.2
File Interpreter ABI Platform
django_countries_hdx-3.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 75.6 kB

Release files / django_countries_hdx-3.0.2.tar.gz

Download URL django_countries_hdx-3.0.2.tar.gz
Size 38.9 kB
Tags Source
SHA-256 checksum
How to use checksums
178b534eec93418fa0b54230004c64412654b921a6cfc5bf894e8924840ccfa2
BLAKE2b-256 checksum
How to use checksums
29f465bafa8cbe443c549f91b61dad172c3113c5cf4055355f9f9e43c287b12a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / django_countries_hdx-3.0.2-py3-none-any.whl

Download URL django_countries_hdx-3.0.2-py3-none-any.whl
Size 36.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
343688a6e5faf96ad2feeb8707872789aef26ce11a9e85cb0560da23f520502e
BLAKE2b-256 checksum
How to use checksums
3b24f1838c55712672361a9b00a29c73571181f1861ef29e0046bca979737bd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release history Release notifications | RSS feed

3.0.3

2 release files

This release

3.0.2 This release

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.2

2 release files

1.1.1

2 release files

1.1

2 release files

1.0

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page