Skip to main content

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 CountryField that accepts both 2-character and 3-character ISO and 3-character GENC codes
  • Admin interface integration

Installation

  1. Install the package:
pip install django-genc
  1. Add 'django_genc' to your INSTALLED_APPS:
INSTALLED_APPS = [
    ...
    'django_genc.apps.GencConfig',
    ...
]
  1. 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


Download files

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

Source Distribution

django_genc-0.1.2.tar.gz (40.5 kB view details)

Uploaded Source

Built Distribution

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

django_genc-0.1.2-py3-none-any.whl (51.7 kB view details)

Uploaded Python 3

File details

Details for the file django_genc-0.1.2.tar.gz.

File metadata

  • Download URL: django_genc-0.1.2.tar.gz
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.0

File hashes

Hashes for django_genc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6ddd4492ea085334489d0e9e2a7b3fdcca393db156d028d3b012edd4e884666a
MD5 21502b25f6d562440e24be426ec082af
BLAKE2b-256 91798b3b4ee34b3d802a38e4b7932bd865fc55dfe0e4fe4a46a2a5a5e651929d

See more details on using hashes here.

File details

Details for the file django_genc-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_genc-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 48a72c7fe76dd50cc942de9f0dacfe95a74b26d70a2d689e77f232e5c3520fdf
MD5 a5d3eb49bd1dc75ec4d2e287aa3084a2
BLAKE2b-256 bbce5fad274957ecef04bceea55b960dd037d66d67ee420406d11a338b2414b2

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