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.1.tar.gz (40.4 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.1-py3-none-any.whl (51.1 kB view details)

Uploaded Python 3

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

Hashes for django_genc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5f60e1c80389ec526538c1e69c240f7926fac0f6fbc71a56d3e36c6c146b8887
MD5 05fc66bd8c0ca3486934bff153624802
BLAKE2b-256 ec2acec9cd1393798e4dca51f92cf767d871983cc4dcddee8c6f77dffcaed839

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_genc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03a973f37869886bd9aae1f5f447059feb1a60f514cef3bc796038154f5fbf8b
MD5 7904968860fc9c1dcee6d5b53912ad06
BLAKE2b-256 2b698258959518a39fd75c35a058f400d77eb651a2cdc60468bf8eb046612d7e

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