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.
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 COUNTRY_CHOICES = ( ("UK", _("United Kingdom")), ("DE", _("Germany")), ("FR", _("France")), ("LT", _("Lithuania")), ) @python_2_unicode_compatible class Location(models.Model): title = models.CharField(_("title"...