A Django app for store places with autocomplete function and a related map to the selected place.
Install dj-places and add it to your installed apps:
$ pip install dj-places
INSTALLED_APPS = (
...
'places',
...
)
Add the following settings and maps api key ( read more here ):
PLACES_MAPS_API_KEY='YourAwesomeUltraSecretKey'
MAP_WIDGET_HEIGHT=480
MAP_OPTIONS={}
MARKER_OPTIONS={}
Then use it in a project:
from places.fields import PlacesField
location = PlacesField()
This enables the following API:
>>> from myapp.models import ModelName
>>> poi = ModelName.objects.get(id=1)
>>> poi.position
Place('Metrocentro, Managua, Nicaragua', 52.522906, 13.41156)
>>> poi.position.place
'Metrocentro, Managua, Nicaragua'
>>> poi.position.latitude
52.522906
>>> poi.position.longitude
13.41156
- Write some test ASAP!
- Support Inline Admin
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements-test.txt
(myenv) $ python runtests.py
Tools used in rendering this package: