Skip to main content

django-places

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


Metadata

Release files for dj-places 5.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dj-places 5.2.1
File Size Uploaded
dj_places-5.2.1.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dj-places 5.2.1
File Interpreter ABI Platform
dj_places-5.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / dj_places-5.2.1.tar.gz

Download URL dj_places-5.2.1.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2004d3db0cee2490aff0479c25867b5b334c4cf9147d74b045e349277dca48f8
BLAKE2b-256 checksum
How to use checksums
e928d9a9ee710a7fd16e1ee6915885c6179db6345f8095399dc9f3435f450c70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.23.0

Release files / dj_places-5.2.1-py3-none-any.whl

Download URL dj_places-5.2.1-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89cd3ddd11d5c3b3e895ac4d80cbc2f0320a38ada571a2a0eccebbed17764b42
BLAKE2b-256 checksum
How to use checksums
fdf75657e5ff0158fa7c0431f19e99a9ef6423edc0ca154cea9f9baf5a9ba3af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.23.0

Release history Release notifications | RSS feed

This release

5.2.1 This release

2 release files

5.2.0

2 release files

5.1.0

1 release file

5.0.0

1 release file

4.0.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.0.0

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

2 release files

1.1.0

1 release file

1.0.5

1 release file

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page