Skip to main content

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

  1. Add dz_locations to your INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        ...
        'dz_locations',
    ]
    
  2. Run migrations to create database tables

    python manage.py makemigrations dz_locations
    python manage.py migrate
    
  3. Include the app URLs in your root URLconf :

     from django.urls import include, path
     urlpatterns = [
        ...,
        path("dzloc", include("dz_locations.urls")),
      ]
    
  4. (Optional) If you want to populate your database with the provided Algerian locations data,
    run the following management command:

    python manage.py newload
    
  5. 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:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes and push them to your fork.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for dz-locations 0.1.6

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

Source distribution (sdist)

Source distribution for dz-locations 0.1.6
File Size Uploaded
dz_locations-0.1.6.tar.gz 59.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dz-locations 0.1.6
File Interpreter ABI Platform
dz_locations-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 121.5 kB

Release files / dz_locations-0.1.6.tar.gz

Download URL dz_locations-0.1.6.tar.gz
Size 59.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e83a0fc68f5955dbdcbfc02ef4cb7e1d61b9eda8c3e282f45c7d8d0e7f2e4e6a
BLAKE2b-256 checksum
How to use checksums
9d563b5e3ad1eed1133c9910db36d4cfaa3791c56761cb41a74167928b6353d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Release files / dz_locations-0.1.6-py3-none-any.whl

Download URL dz_locations-0.1.6-py3-none-any.whl
Size 62.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b933d8d54e66cdd8c02db69ffe61b2b80f1c5de3eab8f16faad1dfc03c306041
BLAKE2b-256 checksum
How to use checksums
40e40a197ab2d5bad863655a2752cbf9a1f4b3ee092d6aaa99af9e7565d42859
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

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