Nigerian States
Django Nigerian States is a comprehensive third-party Django application that provides a robust and efficient way to manage and interact with geopolitical data related to Nigeria. This application is designed to seamlessly integrate with your Django projects, providing pre-defined Django fields for all states, their capitals, local government areas, and geopolitical zones in Nigeria.
Requirements
Python 3.10
Django 5.0.1
Installation Steps
Install Nigerian States using pip:
pip install django_nigerian_statesAdd ‘nigerian_states’ to INSTALLED_APPS in your Django project’s settings.
Migrate your database:
python manage.py makemigrations python manage.py migrateLoad Fixtures:
python manage.py loaddata fixtures
Usage
You can integrate Nigerian States into your Django forms seamlessly. Below is an example:
Example Usage
from django import forms
from nigerian_states.fields import StateFormField, LocalGovernmentField
class AboutForm(forms.ModelForm):
zone = GeoPoliticalZoneField(
label="Zone",
help_text="Select a zone from the dropdown",
widget=forms.Select(attrs={"class": "form-select"}),
)
state = StateField(
label="Name of States",
help_text="Select a state from the dropdown",
widget=forms.Select(
attrs={"class": "form-select", "required": "required"}
),
)
lga = LocalGovernmentField(
label="Local Governments",
help_text="Select a LGA from the dropdown",
widget=forms.Select(
attrs={"class": "form-select", "required": "required"}
),
)
Configuration
You can configure Nigerian States by modifying your Django project settings.py:
DEFAULT_GEO_POLITICAL_ZONES = ["North Central", "North West"]
Setting DEFAULT_GEO_POLITICAL_ZONES restricts the choices for (GeoPoliticalZoneField, StateField, or LocalGovernmentField) to the specified zones.
You can also customize fields further by utilizing additional keyword arguments like empty_label and zones:
from django import forms
from nigerian_states.fields import StateFormField, LocalGovernmentField
from nigerian_states.enums import PoliticalZones
zone = GeoPoliticalZoneField(
label="Zone",
empty_label="Select a GeoPolitical Zone", # the first option in the dropdown
zones=[PoliticalZones.SOUTH_EAST, PoliticalZones.SOUTH_EAST], # limits the field to specified political zones, overriding DEFAULT_GEO_POLITICAL_ZONES
)
Note: In the above, by passing the zones kwargs in the field, It would override the DEFAULT_GEO_POLITICAL_ZONES set in the settings.py
Contributing
Contributions are welcomed and appreciated! Follow these steps to contribute:
Fork the repository.
Create a new branch for your feature or bug fix.
Make changes, ensuring to write tests to confirm your changes did not break anything.
Push the changes to your fork.
Submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Developed by Afeez Lawal
Contact Me:
Email: mailto:lawalafeez052@gmail
LinkedIn: https://www.linkedin.com/in/lawal-afeez/
Github: https://github.com/Afeez31/
Metadata
Release files for django-nigerian-states 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_nigerian_states-1.0.tar.gz | 17.7 kB | Without provenance | Details for django_nigerian_states-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_nigerian_states-1.0-py3-none-any.whl | Python 3 | none | any | Details for django_nigerian_states-1.0-py3-none-any.whl |
Total release size: 39.1 kB
Release files / django_nigerian_states-1.0.tar.gz
| Download URL | django_nigerian_states-1.0.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2fde3c8f35bd2646d50108724d517cd5ad51851073e0fc6159c05b6a8e899c7b
|
|
BLAKE2b-256 checksum How to use checksums |
8e06063648d2ff4d8c5e4f3233d6c921cae36553ad5fea3f1ade97759f876394
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.10
|
Release files / django_nigerian_states-1.0-py3-none-any.whl
| Download URL | django_nigerian_states-1.0-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f32f68689a8d18e994f8936ddfe1dd2f83b198c104bf6634a3b37f217722ce9e
|
|
BLAKE2b-256 checksum How to use checksums |
367cf06396dea6066dd403eaf08be9184c5f85a1bf812469ea8508c395752051
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.10
|
Security for django-nigerian-states 1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.