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/wilaya/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.5.tar.gz (59.4 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.5-py3-none-any.whl (62.0 kB view details)

Uploaded Python 3

File details

Details for the file dz_locations-0.1.5.tar.gz.

File metadata

  • Download URL: dz_locations-0.1.5.tar.gz
  • Upload date:
  • Size: 59.4 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.5.tar.gz
Algorithm Hash digest
SHA256 c34bcc40f004fefb64feaa61e90e5c3fc561bf2c87801ebf84f980ab612f49b2
MD5 8fa8d1be03464b59710646a861459530
BLAKE2b-256 d8b91221649d4bef5c5c4b5c2bbc9ad813292d9398f58fa55003da0051e6dae0

See more details on using hashes here.

File details

Details for the file dz_locations-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: dz_locations-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1b01660177df769930f6a24289f7239a01457fe2378557b03a19890ff5c829e0
MD5 fc71fe0147c27292212d8410ffbcaedf
BLAKE2b-256 23a173d62cdc94709e17ea193469b5fad048dbec26b439708503609ea6fd6a15

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