Coder Social home page Coder Social logo

daweedm / django-places Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oscarmcm/django-places

0.0 0.0 0.0 92 KB

A django app for store places with autocomplete

Home Page: http://oscarmcm.github.io/django-places/

License: MIT License

JavaScript 7.69% Python 76.15% CSS 1.30% HTML 14.86%

django-places's Introduction

PyPI

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):

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:

from django.db import models
from places.fields import PlacesField


class MyLocationModel(models.Model):
    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

For using outside the Django Admin:

<form method="post">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Save">
    {{ form.media }}
</form>

Remember to add the {{ form.media }} in your template.

Demo


Credits


Tools used in rendering this package:

Similar Projects


django-places's People

Contributors

oscarmcm avatar pavillet avatar dryan avatar darwing1210 avatar vanya909 avatar andrewgy8 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.