Skip to main content

Adds extra M49 data to django-countries using hdx-python-country.

Project description

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_countries_hdx-3.0.1.tar.gz (38.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_countries_hdx-3.0.1-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

Details for the file django_countries_hdx-3.0.1.tar.gz.

File metadata

  • Download URL: django_countries_hdx-3.0.1.tar.gz
  • Upload date:
  • Size: 38.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for django_countries_hdx-3.0.1.tar.gz
Algorithm Hash digest
SHA256 8d8ca0ec772924905f1008ea821051cec3bd6746f39df2b32efcd35974bbfcf3
MD5 1473ca6c3df02d75d7bca00f2f24fd30
BLAKE2b-256 b9855894248ee229e50ed7eef2ccd8180cae0297d33b55d4975477bdf4411e68

See more details on using hashes here.

File details

Details for the file django_countries_hdx-3.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_countries_hdx-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f2d1ebf91986f9f601ec25e5247dc262d8eeccfdabeb732d0340401a08f38fc2
MD5 57c61845a7a101787800a776f89475e2
BLAKE2b-256 3458655b255f554c9b869721b3b7d8330dbee02f631e4689d4d406bc0e2a06b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page