Algerian Wilaya & Commune data for Django projects
Project description
dz_locations
DZ Locations is a Django package that provides Algerian wilayas (states) and communes (municipalities) ready to use in your Django projects.
This package helps you quickly populate your database with all Algerian locations and access them via Django Admin or API.
Installation
Install the package via pip:
pip install dz-locations
Features
- ✅ Ready-to-use Wilayas & Communes of Algeria
- ✅ Arabic & French names
- ✅ Longitude & Latitude for mapping
- ✅ DRF serializers included
Usage
-
Add
dz_locationsto yourINSTALLED_APPSinsettings.py:INSTALLED_APPS = [ ... 'dz_locations', ]
-
Run migrations to create database tables
python manage.py makemigrations dz_locations python manage.py migrate
-
Include the app URLs in your root URLconf :
from django.urls import include, path urlpatterns = [ ..., path("dzloc", include("dz_locations.urls")), ]
-
(Optional) If you want to populate your database with the provided Algerian locations data,
run the following management command:python manage.py newload
-
Access the data:
- Via Django Admin (Wilayas & Communes models).
- Or via the provided serializers for API development (Django REST Framework).
Use Cases
Example usage with the included endpoints:
from django.urls import path
from .views import WilayaListAPI, get_wliaya
urlpatterns = [
path('wilayas/', WilayaListAPI.as_view(), name='wilaya-list'),
path('wilaya/<str:code>/', get_wliaya, name='get-wilaya-by-code'),
]
Example Requests
-
Get all Wilayas
GET /dzloc/wilayas/ -
Get a specific Wilaya by code
GET /dzloc/wilaya/01/
Example Response (for /dzloc/wilayas/01/)
{
"id": 1,
"code": "01",
"name": "Adrar",
"ar_name": "أدرار",
"longitude": 27.9766155,
"latitude": -0.20396,
"communes": [
{
"id": 1,
"post_code": "01001",
"name": "Adrar",
"ar_name": "أدرار",
"longitude": 27.9763317,
"latitude": -0.4841573
}
,
]
}
Data Source
The JSON data used in this project is sourced from:
👉 Wilaya-Of-Algeria by AbderrahmeneDZ
Contributing
Contributions are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes and push them to your fork.
- Submit a pull request.
License
This project is licensed under the MIT 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
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 dz_locations-0.1.6.tar.gz.
File metadata
- Download URL: dz_locations-0.1.6.tar.gz
- Upload date:
- Size: 59.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e83a0fc68f5955dbdcbfc02ef4cb7e1d61b9eda8c3e282f45c7d8d0e7f2e4e6a
|
|
| MD5 |
fb2d04123cf507f3104cefcf9c952159
|
|
| BLAKE2b-256 |
9d563b5e3ad1eed1133c9910db36d4cfaa3791c56761cb41a74167928b6353d2
|
File details
Details for the file dz_locations-0.1.6-py3-none-any.whl.
File metadata
- Download URL: dz_locations-0.1.6-py3-none-any.whl
- Upload date:
- Size: 62.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b933d8d54e66cdd8c02db69ffe61b2b80f1c5de3eab8f16faad1dfc03c306041
|
|
| MD5 |
eb9a6e33af2e96651ca0f6cb7df22a35
|
|
| BLAKE2b-256 |
40e40a197ab2d5bad863655a2752cbf9a1f4b3ee092d6aaa99af9e7565d42859
|