django-geocoder

Python geocoder wrapper for Django, inspired by Ruby geocoder.


License
MIT
Install
pip install django-geocoder==0.2.1

Documentation

django-geocoder

PyPI version Build Status

Python geocoder wrapper for Django, inspired by Ruby geocoder.

How it works

Looks for an geocoded_by attribute (default = address) in your GEOCODER_MODEL and fills the required_address_components with geocoding data.

Install

# settings.py
GEOCODER_MODEL = 'test_app.Place'

Usage

As a mixin

from django.db import models
from django_geocoder.mixins import GeoMixin

class Place(models.Model, GeoMixin):
    address = models.CharField()

    # [...] locality, postal_code, etc...

    required_address_components = {
        'locality': ['locality'],
        'postal_code': ['postal_code'],
    }

As a Django command

Performs a geocoding on all objects

$ python manage.py batch_geocode

As an helper for caching

import django_geocoder as geocoder

# calls `geocoder.get()` under the hoods
result = geocoder.get("Some address")

# same as above, with caching
result = geocoder.get_cached("Some address")