Skip to content

Location field and widget for Django. It supports Google Maps, OpenStreetMap and Mapbox

License

Notifications You must be signed in to change notification settings

fpoulain/django-location-field

 
 

Repository files navigation

Django Location Field

Let users pick locations using a map widget and store its latitude and longitude.

Stable version: django-location-field==2.0.6

License: MIT

Status

Build Status

Tests are performed with Python 2.7, Django 1.8 .. 1.10 and SpatiaLite. We'd like to have automated tests for Python 3 too, but it looks like pysqlite (which is used for testing) does not support it yet, so it's blocking us. You can get more details in the tox.ini file.

Features

  • Support for multiple map engines, like Google Maps, OpenStreetMap and Mapbox.
  • Support for multiple search engines, like Google, Nominatim and Yandex.
  • Works with both Spatial and non-Spatial databases.

Compatibility

  • Django 1.8 to 1.10
  • Python 2.7 to 3.5

Spatial Databases

  • PostGIS
  • SpatiaLite

Installation

  1. Install through pip (or manually place it on your PYTHONPATH).

    pip install django-location-field

  2. Add location_field.apps.DefaultConfig to INSTALLED_APPS your settings.py file

For example, PostGIS:

https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/postgis/

Basic usage (using Spatial Database)

from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
from location_field.models.spatial import LocationField

class Place(models.Model):
    city = models.CharField(max_length=255)
    location = LocationField(based_fields=['city'], zoom=7, default=Point(1.0, 1.0))
    objects = models.GeoManager()

Look that you must put models.GeoManager() in your model, or some errors will occur.

Basic usage (without Spatial Database)

from django.db import models
from location_field.models.plain import PlainLocationField

class Place(models.Model):
    city = models.CharField(max_length=255)
    location = PlainLocationField(based_fields=['city'], zoom=7)

Screenshot

Screenshot

About

Location field and widget for Django. It supports Google Maps, OpenStreetMap and Mapbox

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 55.4%
  • CSS 22.7%
  • Python 21.6%
  • HTML 0.3%