Skip to main content

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

  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.

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

dz_locations-0.1.6.tar.gz (59.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dz_locations-0.1.6-py3-none-any.whl (62.0 kB view details)

Uploaded Python 3

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

Hashes for dz_locations-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e83a0fc68f5955dbdcbfc02ef4cb7e1d61b9eda8c3e282f45c7d8d0e7f2e4e6a
MD5 fb2d04123cf507f3104cefcf9c952159
BLAKE2b-256 9d563b5e3ad1eed1133c9910db36d4cfaa3791c56761cb41a74167928b6353d2

See more details on using hashes here.

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

Hashes for dz_locations-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b933d8d54e66cdd8c02db69ffe61b2b80f1c5de3eab8f16faad1dfc03c306041
MD5 eb9a6e33af2e96651ca0f6cb7df22a35
BLAKE2b-256 40e40a197ab2d5bad863655a2752cbf9a1f4b3ee092d6aaa99af9e7565d42859

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page