Global-ready Django apps from day one. Jurisdictions, dial codes, flags, holidays, timezones, languages & more.
Project description
GeoCanon
Global-Ready Django Apps From Day One
Jurisdictions. Dial Codes. Flags. Timezones. Holidays. Languages. One Package.
What is GeoCanon?
GeoCanon is a locale & jurisdiction toolkit for Django that gives your app global awareness out of the box.
Instead of hand-rolling country lists, phone validation, timezone lookups, and holiday calendars, you import one consistent library and ship internationally from your first deploy.
The Problem
# Scattered across your codebase...
COUNTRIES = [("US", "United States"), ...] # hand-maintained
DIAL_CODES = {"+1": "US", ...} # incomplete
TIMEZONE_MAP = {"US": "America/New_York"} # 8 entries
# No holiday detection, no flag icons, no language defaults
The Solution
from geo_canon import (
get_jurisdiction_choices, # 190+ countries, sorted, translatable
get_dial_code, # "Romania" → "+40"
validate_phone, # per-country regex validation
get_flag_css_class, # "Romania" → "fi-ro"
get_current_local_time, # "Romania" → aware datetime in Europe/Bucharest
get_language_for_jurisdiction, # "Romania" → "ro"
format_duration, # 3661 → "1 hour, 1 minute, 1 second"
)
# Optional: holiday detection
from geo_canon.holidays import is_public_holiday
is_public_holiday("Romania", date(2025, 12, 25)) # True
Quick Start
1. Install
# Core (zero non-Django dependencies)
pip install geocanon
# With optional extras
pip install geocanon[holidays] # Public holiday detection
pip install geocanon[timezones] # pytz fallback for Python <3.9
pip install geocanon[all] # Everything
Available extras:
| Extra | What it adds |
|---|---|
holidays |
Public holiday detection (140+ countries) |
timezones |
pytz fallback for legacy Python |
all |
Everything above |
2. Configure (optional)
# settings.py — zero config required, but you CAN customise:
from geo_canon.settings import GeoCanonSettings
GEOCANON = GeoCanonSettings(
default_jurisdiction="United Kingdom",
default_language="en",
timezone_overrides={"My Custom Region": "Europe/London"},
)
3. Use Anywhere
from geo_canon import get_dial_code, get_flag_css_class, get_current_local_time
# Phone dial codes
get_dial_code("Romania") # "+40"
get_dial_code("United States") # "+1"
# Flag CSS classes (for flag-icons library)
get_flag_css_class("Romania") # "fi-ro"
# Current local time
get_current_local_time("Japan") # datetime in Asia/Tokyo
# Language defaults
from geo_canon import get_language_for_jurisdiction
get_language_for_jurisdiction("France") # "fr"
# Duration formatting (i18n-aware)
from geo_canon import format_duration
format_duration(7200) # "2 hours"
4. Django Forms
from geo_canon.jurisdictions.forms import JurisdictionContextSwitchForm
# Drop-in jurisdiction selector
form = JurisdictionContextSwitchForm()
5. Middleware
# settings.py
MIDDLEWARE = [
...
"geo_canon.jurisdictions.middleware.JurisdictionMiddleware",
]
# Now every request has request.jurisdiction
Modules
| Module | Status | Description |
|---|---|---|
| Jurisdictions | Production | 190+ countries with translatable names, forms, middleware |
| Dial Codes | Production | International dial codes + per-country phone validation |
| Flags | Production | Country → ISO-3166 flag CSS class mapping |
| Timezones | Production | 200+ jurisdiction → IANA timezone mappings |
| Languages | Production | Language choices + jurisdiction → default language |
| Duration | Production | i18n-aware human-readable duration formatting |
| Holidays | Production | Public holiday detection for 140+ countries |
| Settings | Production | Pydantic-validated configuration |
Features
- 190+ jurisdictions — sorted, translatable, with O(1) lookups
- Phone validation — per-country regex patterns for national number formats
- Flag icons — CSS class mapping compatible with flag-icons
- 200+ timezones — uses
zoneinfo(3.9+) withpytzfallback - Holiday detection — powered by the battle-tested
holidayslibrary - 75+ languages — ISO 639-1 choices with jurisdiction → language mapping
- Duration formatting — respects Django's active translation
- Jurisdiction middleware — automatic
request.jurisdictionon every request - Django form fields — drop-in
JurisdictionChoiceFieldand context-switch form - Pydantic settings — type-safe configuration with sensible defaults
- Rich exceptions — actionable error messages with hints and docs links
- Zero config — works with defaults, customise when you need to
- PEP 561 —
py.typedmarker for mypy/pyright
Why GeoCanon?
- One Source of Truth — no more scattered country lists and timezone dicts
- Production-Tested — extracted from a live Django platform serving multiple jurisdictions
- Translatable — all labels use
gettext_lazyfor full i18n support - Minimal Dependencies — only Django required; extras are truly optional
- Type-Safe — Pydantic validation, type hints throughout, PEP 561 compliant
- Extensible — override timezones, holiday mappings, and more via settings
License
MIT — Because global-ready Django should be free.
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 geocanon-0.1.0.tar.gz.
File metadata
- Download URL: geocanon-0.1.0.tar.gz
- Upload date:
- Size: 32.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1653d7120c19d89c5fa7fccd287f9beebe246377b857b5d484a8c50e6aede82
|
|
| MD5 |
107784c721b0bdc9f98dd78a9ec3c1f1
|
|
| BLAKE2b-256 |
0b46d209dd357cf1fe21718a5948222739e0adcdfea554636c5c3f1aca1043f4
|
Provenance
The following attestation bundles were made for geocanon-0.1.0.tar.gz:
Publisher:
publish.yaml on Tunet-xyz/geo_canon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geocanon-0.1.0.tar.gz -
Subject digest:
d1653d7120c19d89c5fa7fccd287f9beebe246377b857b5d484a8c50e6aede82 - Sigstore transparency entry: 988777692
- Sigstore integration time:
-
Permalink:
Tunet-xyz/geo_canon@9a3184e9f555c36a90a6cf3596f8c193ae0be85f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Tunet-xyz
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@9a3184e9f555c36a90a6cf3596f8c193ae0be85f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file geocanon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: geocanon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13441c43c0fd8baa7e2e98f588d75f0a9ce090c65532dc1e79f67fd736c501c8
|
|
| MD5 |
f32cdae919abd4b62c193198222a3e33
|
|
| BLAKE2b-256 |
f5c051c5b7c188136b923e199635bc736e92f5986c31c03797655c9412fd836f
|
Provenance
The following attestation bundles were made for geocanon-0.1.0-py3-none-any.whl:
Publisher:
publish.yaml on Tunet-xyz/geo_canon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geocanon-0.1.0-py3-none-any.whl -
Subject digest:
13441c43c0fd8baa7e2e98f588d75f0a9ce090c65532dc1e79f67fd736c501c8 - Sigstore transparency entry: 988777813
- Sigstore integration time:
-
Permalink:
Tunet-xyz/geo_canon@9a3184e9f555c36a90a6cf3596f8c193ae0be85f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Tunet-xyz
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@9a3184e9f555c36a90a6cf3596f8c193ae0be85f -
Trigger Event:
workflow_dispatch
-
Statement type: