Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oscarmcm/django-places
A django app for store places with autocomplete
https://github.com/oscarmcm/django-places
autocomplete autocompletion cookiecutter django geolocation google-maps google-maps-api python
Last synced: 3 days ago
JSON representation
A django app for store places with autocomplete
- Host: GitHub
- URL: https://github.com/oscarmcm/django-places
- Owner: oscarmcm
- License: mit
- Created: 2015-11-26T23:19:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-31T07:47:25.000Z (10 months ago)
- Last Synced: 2024-09-14T12:49:36.994Z (about 2 months ago)
- Topics: autocomplete, autocompletion, cookiecutter, django, geolocation, google-maps, google-maps-api, python
- Language: Python
- Homepage: http://oscarmcm.github.io/django-places/
- Size: 95.7 KB
- Stars: 74
- Watchers: 7
- Forks: 21
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.rst
- License: LICENSE
- Authors: AUTHORS.md
Awesome Lists containing this project
README
# [django-places](https://pypi.org/project/dj-places/)
[![PyPI](https://badge.fury.io/py/dj-places.png)](https://badge.fury.io/py/dj-places)
A Django app for store places with autocomplete function and a related map to the selected place.
## Quickstart
----------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](https://developers.google.com/maps/documentation/javascript/reference/map)):
```python
PLACES_MAPS_API_KEY='YourAwesomeUltraSecretKey'
PLACES_MAP_WIDGET_HEIGHT=480
PLACES_MAP_OPTIONS='{"center": { "lat": 38.971584, "lng": -95.235072 }, "zoom": 10}'
PLACES_MARKER_OPTIONS='{"draggable": true}'
```## Usage
--------Then use it in a project:
```python
from django.db import models
from places.fields import PlacesFieldclass MyLocationModel(models.Model):
location = PlacesField()```
This enables the following API:
```python
>>> 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
```For using outside the Django Admin:
```html
{% csrf_token %}
{{ form.as_p }}
{{ form.media }}```
Remember to add the `{{ form.media }}` in your template.## Demo
------![](http://g.recordit.co/LheQH0HDMR.gif)
### Credits
---------Tools used in rendering this package:
* [Cookiecutter](https://github.com/audreyr/cookiecutter)
* [cookiecutter-djangopackage](https://github.com/pydanny/cookiecutter-djangopackage)
* [jquery-geocomplete](https://github.com/ubilabs/geocomplete) (_no longer used in the project._)### Similar Projects
------------* [Django Location Field](https://github.com/caioariede/django-location-field)
* [Django GeoPosition](https://github.com/philippbosch/django-geoposition)