Inserting a map into a change form
Google Maps offer a JavaScript API to insert maps into your websites. In this recipe, we will create a locations
app with the Location
model and extend the template of the change form in order to add a map where an administrator can find and mark geographical coordinates of a location.
Getting ready
We will start with the locations
app that should be put under INSTALLED_APPS
in the settings. Create a Location
model there with a title, description, address, and geographical coordinates, as follows:
# locations/models.py # -*- coding: UTF-8 -*- from __future__ import unicode_literals from django.db import models from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import python_2_unicode_compatible ...
Get Web Development with Django Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.