Skip to main content

Django library package for Locations/Addresses in the Philippines based on Philippine Standard Geographic Code(PSGC)

Project description

Philippines Address Management

This Django app provides models to manage and store hierarchical address information in the Philippines, including Regions, Provinces, Municipalities, and Barangays.

PyPi URL: phil-loc

Models Overview

1. Region

  • Represents a region in the Philippines.

  • Fields:

    • name: The name of the region.
    • psgc_code: The Philippine Standard Geographic Code for the region.
    • reg_code: A unique code for the region.
    • country: The country the region belongs to (default is "Philippines").
  • Relationships:

    • Linked to the Province model.

2. Province

  • Represents a province within a region in the Philippines.

  • Fields:

    • name: The name of the province.
    • psgc_code: The Philippine Standard Geographic Code for the province.
    • prov_code: A unique code for the province.
    • reg_code: The region code to which the province belongs.
  • Relationships:

    • Linked to the Region and Municipality models.

3. Municipality

  • Represents a municipality within a province in the Philippines.

  • Fields:

    • name: The name of the municipality.
    • psgc_code: The Philippine Standard Geographic Code for the municipality.
    • city_mun_code: A unique code for the municipality.
    • prov_code: The province code to which the municipality belongs.
    • reg_code: The region code to which the municipality belongs.
  • Relationships:

    • Linked to the Province and Barangay models.

4. Barangay

  • Represents a barangay (smallest administrative division) within a municipality in the Philippines.

  • Fields:

    • name: The name of the barangay.
    • brgy_code: A unique code for the barangay.
    • city_mun_code: The municipality code to which the barangay belongs.
    • prov_code: The province code to which the barangay belongs.
    • reg_code: The region code to which the barangay belongs.
  • Relationships:

    • Linked to the Municipality model.

5. PhAddress

  • Represents a full address in the Philippines, including the hierarchical structure from region down to barangay.

  • Fields:

    • country: The country the address belongs to (default is "Philippines").
    • unit_home_street: Detailed street address, unit number, or home information.
    • zip_code: Postal code.
    • district_id: An optional district identifier.
    • created_at: Timestamp when the address was created.
    • updated_at: Timestamp when the address was last updated.
  • Relationships:

    • Linked to the Region, Province, Municipality, and Barangay models.

Usage

Installation

To include this app in your Django project:

  1. Add phil_loc to INSTALLED_APPS in your settings.py.

  2. Run migrations to create the necessary database tables:

    python manage.py migrate
    
  3. Data seeding

python manage.py seed_ph_locations

Example Usage

from phil_loc.models import PhAddress

# Create a new address
address = PhAddress.objects.create(
    country='PH',
    region=region_instance,
    province=province_instance,
    municipality=municipality_instance,
    barangay_district=barangay_instance,
    unit_home_street='123 Example Street',
    zip_code=1234
)

License

This project is licensed under the MIT License.


This README gives an overview of the models, their fields, and relationships, and provides a basic usage example for the PhAddress model. Adjust the phil_loc placeholders and add any additional information as needed for your specific application.

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

phil_loc-0.6.0.tar.gz (548.6 kB view details)

Uploaded Source

Built Distribution

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

phil_loc-0.6.0-py3-none-any.whl (606.5 kB view details)

Uploaded Python 3

File details

Details for the file phil_loc-0.6.0.tar.gz.

File metadata

  • Download URL: phil_loc-0.6.0.tar.gz
  • Upload date:
  • Size: 548.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for phil_loc-0.6.0.tar.gz
Algorithm Hash digest
SHA256 5a10cc6e72899dbef8ce6b1b66e484486d75e11584745699cb5f1507efb240b8
MD5 26b2d9aa8d59367a101c1dbf4fc86473
BLAKE2b-256 123a2be92378b581e4b3ec2bbeacc65bbef048b503d4ef83c97ce8343aa68612

See more details on using hashes here.

File details

Details for the file phil_loc-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: phil_loc-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 606.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for phil_loc-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a128130775c392cc36fd3f91cd12a7cab23e5b447eb8256323ad96d89da29c8c
MD5 1d8889b69d048c24dfb0f247984a0ba9
BLAKE2b-256 bde624ee08322ca97b19cc6a586291a8488e4f54adeee03911b99a378d388f35

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