A django app for working with GENC country codes
Project description
django-genc
A reusable Django app for working with GENC (Geopolitical Entities, Names, and Codes) country codes. Source data comes from the NGA site and the CIA World Fact Book.
Features
- Store and manage GENC country codes with their ISO equivalents
- Custom
CountryFieldthat accepts both 2-character and 3-character ISO and 3-character GENC codes - Admin interface integration
Installation
- Install the package:
pip install django-genc
- Add 'django_genc' to your INSTALLED_APPS:
INSTALLED_APPS = [
...
'django_genc.apps.GencConfig',
...
]
- Run migrations:
python manage.py migrate
Usage
Models
from django.db import models
from django_genc.models import CountryField
class MyModel(models.Model):
country = CountryField()
API
CountryField
A custom field that can handle both 2-digit ISO and 3-digit GENC codes.
from django_genc.models import CountryField
class MyModel(models.Model):
country = CountryField()
The field will:
- Store values as 3-digit GENC codes in the database
- Accept both 2-digit ISO and 3-digit GENC codes as input
- Automatically convert ISO codes to GENC codes
- Validate that the code exists in the database
CountryCode Model
The base model for storing country codes:
from django_genc.models import CountryCode
# Get a country by GENC code
country = CountryCode.objects.get(genc_code='USA')
# Get a country by ISO code
country = CountryCode.objects.get(iso_code='US')
# Look up a country by a code under either standard
country = CountryCode.objects.get_by_code('US')
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_genc-0.1.1.tar.gz.
File metadata
- Download URL: django_genc-0.1.1.tar.gz
- Upload date:
- Size: 40.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f60e1c80389ec526538c1e69c240f7926fac0f6fbc71a56d3e36c6c146b8887
|
|
| MD5 |
05fc66bd8c0ca3486934bff153624802
|
|
| BLAKE2b-256 |
ec2acec9cd1393798e4dca51f92cf767d871983cc4dcddee8c6f77dffcaed839
|
File details
Details for the file django_genc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: django_genc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 51.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03a973f37869886bd9aae1f5f447059feb1a60f514cef3bc796038154f5fbf8b
|
|
| MD5 |
7904968860fc9c1dcee6d5b53912ad06
|
|
| BLAKE2b-256 |
2b698258959518a39fd75c35a058f400d77eb651a2cdc60468bf8eb046612d7e
|