Skip to main content
### <In English>

`django-google-maps` is a simple application that provides the basic
hooks into google maps V3 api for use in Django models from Django
version 1.11+.

Starting with `django-google-maps` version (0.7.0), Django 1.11+ is
required because Django changed their widget template rendering system.
Version 0.8.0 supports Django 2.0+, and as such removes support for Python 2.7

I'm using this to allow someone from the admin panels to type a
freeform address, have the address geocoded on change and plotted
on the map. If the location is not 100% correct, the user can
drag the marker to the correct spot and the geo coordinates will
update.

### Status
[![Build Status](https://travis-ci.org/madisona/django-google-maps.png)](https://travis-ci.org/madisona/django-google-maps)

USAGE:
------
- include the `django_google_maps` app in your `settings.py`
- Add your Google Maps API Key in your `settings.py` as `GOOGLE_MAPS_API_KEY`
- create a model that has both an address field and geolocation field

```python
from django.db import models
from django_google_maps import fields as map_fields

class Rental(models.Model):
address = map_fields.AddressField(max_length=200)
geolocation = map_fields.GeoLocationField(max_length=100)
```

- in the `admin.py` include the following as a formfield_override

```python
from django.contrib import admin
from django_google_maps import widgets as map_widgets
from django_google_maps import fields as map_fields

class RentalAdmin(admin.ModelAdmin):
formfield_overrides = {
map_fields.AddressField: {'widget': map_widgets.GoogleMapsAddressWidget},
}
```

- To change the map type (`hybrid` by default), you can add an html attribute
on the `AddressField` widget. The list of allowed values is: `hybrid`, `roadmap`, `satellite`, `terrain`

```python
from django.contrib import admin
from django_google_maps import widgets as map_widgets
from django_google_maps import fields as map_fields

class RentalAdmin(admin.ModelAdmin):
formfield_overrides = {
map_fields.AddressField: {
'widget': map_widgets.GoogleMapsAddressWidget(attrs={'data-map-type': 'roadmap'})},
}
```

That should be all you need to get started.

I also like to make the geolocation field readonly in the admin so a user
(myself) doesn't accidentally change it to a nonsensical value. There is
validation on the field so you can't enter an incorrect value, but you could
enter something that is not even close to the address you intended.

When you're displaying the address back to the user, just request the map
using the geocoordinates that were saved in your model. Maybe sometime when
I get around to it I'll see if I can create a method that will build that
into the model.





Metadata

Release files for django-google-maps 0.11.0

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

Source distribution (sdist)

Source distribution for django-google-maps 0.11.0
File Size Uploaded
django-google-maps-0.11.0.tar.gz 8.7 kB Details

Release files / django-google-maps-0.11.0.tar.gz

Download URL django-google-maps-0.11.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e1190f0a3644564bed9b1ea9d704cb4fa87c33dd2546ff531534832f73966b0f
BLAKE2b-256 checksum
How to use checksums
9ae20b549ac267f218253b963d519d1b9697dbbe4a8852cdd001cafa8197277a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/2.7

Release history Release notifications | RSS feed

0.14.0

2 release files

0.13.0

2 release files

0.12.2

1 release file

0.12.1

1 release file

0.12.0

1 release file

This release

0.11.0 This release

1 release file

0.10.1

1 release file

0.10.0

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

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