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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_countries_hdx-3.0.3.tar.gz | 39.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_countries_hdx-3.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 75.9 kB
Release files / django_countries_hdx-3.0.3.tar.gz
| Download URL | django_countries_hdx-3.0.3.tar.gz |
|---|---|
| Size | 39.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b27040b356d2db2f1e74fc03b7dfac8675bc777f4ca3bb32ed209d34967f7927
|
|
BLAKE2b-256 checksum How to use checksums |
d729135850210057c474bd94003dd8d9301940d84c8ec76ce8ff421054c3e82f
|
| 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.3-py3-none-any.whl
| Download URL | django_countries_hdx-3.0.3-py3-none-any.whl |
|---|---|
| Size | 36.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0d034eb07fb50a9e94fe037c3e36a87fd21d6918d0641500adb9a87fe45ae38
|
|
BLAKE2b-256 checksum How to use checksums |
a0a3b1414b6e5c565d2a09c7591c8a100ce81ca04e9a0d3c893e9687ece4f6d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|