Django Location Field
Allows users to input locations based on latitude and longitude, using a Google maps widget.
- The map will automatically update after changing a field based on
- Works with both Spatial and non-Spatial databases
- Works perfectly with formsets
- Django 1.6 and 1.7
- Python 2.7 and 3.x
It was only tested with PostGIS but may work with other Spatial Databases.
Install through pip (or manually place it on your
pip install django-location-field
Create a Spatial Database (optional)
For example, PostGIS:
- Add to your
INSTALLED_APPS = ( ... 'location_field', ... )
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, 1)) 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)