Skip to main content

django-naija

Django and Django REST framework fields for Nigerian data, built on naija-data: phone numbers (strict NCC validation), NUBAN account numbers (CBN check digit), vehicle plate numbers, states and LGAs.

Website and playground: https://naija-data.asgatcreation.workers.dev · REST API: https://naija-data-api.asgatcreation.workers.dev/v1

pip install django-naija            # Django fields, forms and validators
pip install "django-naija[rest]"    # plus Django REST framework fields

Requires Python 3.10+ and Django 5.2+.

Models

from django.db import models
from django_naija.fields import LGAField, NigerianPhoneField, NUBANField, PlateNumberField, StateField

class Customer(models.Model):
    phone = NigerianPhoneField(types=["mobile"])   # stored as "+2348031234567"
    state = StateField()                           # stored as "LA", 37 choices
    lga = LGAField()                               # stored as "NG025011", 774 choices grouped by state
    plate = PlateNumberField(blank=True)           # stored as "KJA123AB"
    account_number = NUBANField(blank=True)        # stored as "0123456789"

Choices are loaded lazily (Django's callable choices), so migrations stay small.

Forms

from django import forms
from django_naija import forms as ngforms

class PayoutForm(ngforms.StateLGAFormMixin, ngforms.NUBANFormMixin, forms.Form):
    phone = ngforms.NigerianPhoneField(types=["mobile"])
    state = ngforms.StateField()
    lga = ngforms.LGAField()            # limited to the chosen state; must belong to it
    bank = ngforms.BankField()          # banks with a CBN code
    account_number = ngforms.NUBANField()  # checked against the chosen bank

For a dependent state → LGA menu, django_naija.choices.lga_choices("LA") returns the LGAs of one state; the example project serves it as JSON at /lgas/?state=Lagos.

Django REST framework

from rest_framework import serializers
from django_naija import rest_framework as ngdrf

class PayoutSerializer(serializers.Serializer):
    phone = ngdrf.NigerianPhoneField(types=["mobile"])
    state = ngdrf.StateField()          # also accepts "Lagos", "Abuja", "FCT"
    lga = ngdrf.LGAField()              # also accepts INEC codes and unambiguous names
    bank = ngdrf.BankField()            # also accepts "058" or "GTB"
    account_number = ngdrf.NUBANField()

    class Meta:
        validators = [ngdrf.LGAInStateValidator(), ngdrf.NUBANBankValidator()]

Error messages

Every failure has a clear, translatable message and a machine-readable code, e.g. reserved → "This number range is reserved and not in service.", check_digit → "This account number is not valid for the selected bank.". See django_naija/messages.py.

Example project

example/ is a small Django project using every field (model, form, DRF API, dependent LGA endpoint). The tests in tests/ run against it:

pip install -e "packages/python" -e "packages/django[test]"
cd packages/django && python -m pytest

Plate numbers: only the format is checked. FRSC does not publish its list of LGA plate codes, so plates are not mapped to LGAs yet.

Licence: MIT. Data from naija-data: CC BY 4.0, Akanji Oluwaseun Gabriel.

Metadata

Release files for django-naija 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-naija 0.1.1
File Size Uploaded
django_naija-0.1.1.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-naija 0.1.1
File Interpreter ABI Platform
django_naija-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / django_naija-0.1.1.tar.gz

Download URL django_naija-0.1.1.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3ecea6fe7f494bde3395fde4eee3641511f4c9f53f423954807e1ad663f42d09
BLAKE2b-256 checksum
How to use checksums
7e42830bb730d2658e09bb54d4c707cdef4d3a7463bf99e7d849a8ad9fb2084e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / django_naija-0.1.1-py3-none-any.whl

Download URL django_naija-0.1.1-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a198bbd7a99f45c221bd33e5a40ec7385a37efaaec1bcf007b07dfd9b6e9eee0
BLAKE2b-256 checksum
How to use checksums
eebaab694ce4463c5013caa0a731178a3b990b5116e372855e093f62a64d23d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.0

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page