Skip to main content

Django integration for address verification and geocoding. Provides Django fields, widgets, and admin integration for the geoaddress library.

Project description

django-geoaddress

Django integration for address verification and geocoding. Provides Django fields, widgets, and admin integration for the geoaddress library.

Installation

pip install django-geoaddress

Features

  • Django Model Fields: GeoaddressField for storing address data in Django models
  • Autocomplete Widget: Interactive address autocomplete widget with real-time suggestions
  • Admin Integration: Django admin interface for managing addresses and providers
  • Multiple Providers: Support for multiple geocoding providers (Google Maps, Mapbox, Nominatim, etc.)
  • Virtual Models: Uses django-virtualqueryset for dynamic provider and address models
  • Address Management: View, search, and manage addresses through Django admin

Quick Start

1. Add to INSTALLED_APPS

INSTALLED_APPS = [
    # ...
    'django_geoaddress',
]

2. Include URLs

# urls.py
from django.urls import path, include

urlpatterns = [
    # ...
    path('geoaddress/', include('django_geoaddress.urls')),
]

3. Use in Models

from django.db import models
from django_geoaddress.fields import GeoaddressField

class MyModel(models.Model):
    address = GeoaddressField()
    # ... other fields

4. Use in Forms

The GeoaddressField automatically uses the GeoaddressAutocompleteWidget which provides:

  • Real-time address autocomplete
  • Address search across multiple providers
  • Structured address data storage

Address Field

The GeoaddressField stores address data as JSON with the following structure:

{
    "text": "Full formatted address string",
    "reference": "Backend reference ID",
    "address_line1": "Street number and name",
    "address_line2": "Building, apartment (optional)",
    "city": "City name",
    "postal_code": "Postal/ZIP code",
    "state": "State/region/province",
    "country": "Country name",
    "country_code": "ISO country code (e.g., FR, US, GB)",
    "latitude": 48.8566,
    "longitude": 2.3522,
    "backend_name": "nominatim",
    "geoaddress_id": "nominatim-123456"
}

Admin Interface

Django-geoaddress provides admin interfaces for:

  • Address Management: View and manage addresses with search and filtering
  • Provider Management: View available geocoding providers and their capabilities
  • Address Autocomplete: Interactive autocomplete in admin forms

Access the admin at:

  • Addresses: /admin/django_geoaddress/address/
  • Providers: /admin/django_geoaddress/provider/

Supported Providers

The library supports multiple geocoding providers through the geoaddress library:

Free providers (no API key required):

  • Nominatim (OpenStreetMap)
  • Photon (Komoot/OSM)

Paid/API key providers:

  • Google Maps
  • Mapbox
  • LocationIQ
  • OpenCage
  • Geocode Earth
  • Geoapify
  • Maps.co
  • HERE

Configuration

Provider Configuration

Configure geocoding providers in your Django settings or through environment variables. Each provider may require API keys or specific configuration.

Example:

# settings.py
GEOADDRESS_PROVIDERS = {
    'google_maps': {
        'api_key': 'your-api-key',
    },
    'mapbox': {
        'api_key': 'your-api-key',
    },
}

Requirements

  • Django >= 3.2
  • Python >= 3.10
  • geoaddress (automatically installed as dependency)
  • django-virtualqueryset (for virtual models)

Development

# Clone the repository
git clone https://github.com/octolo/django-geoaddress.git
cd django-geoaddress

# Install in development mode
pip install -e .
pip install -e ".[dev]"

License

MIT License - see LICENSE file for details.

Links

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

django_geoaddress-1.0.2.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

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

django_geoaddress-1.0.2-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file django_geoaddress-1.0.2.tar.gz.

File metadata

  • Download URL: django_geoaddress-1.0.2.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_geoaddress-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c2e816472d1c0cff79514e8bdc33b791b2033a606659c50993f89555ef267136
MD5 64aaf509f1f54f070ff041b0ca7d6f2e
BLAKE2b-256 9082cf9604417a24452d76c6fbd1d1b0dcfe305a7dfe308e032daee781c37f39

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_geoaddress-1.0.2.tar.gz:

Publisher: release.yml on octolo/python-geoaddress

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_geoaddress-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_geoaddress-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3707575fdd7986e1114a567ea9fff0186ca24bcbc89e8dcac97a70e7ee5c105c
MD5 698f36960e98b62e9ea2413f7e76840b
BLAKE2b-256 3f2c5a6d4e5643963e7ae5d0a2f22c5f20525d6378b05b50c3fa1d0f9e727035

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_geoaddress-1.0.2-py3-none-any.whl:

Publisher: release.yml on octolo/python-geoaddress

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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