My favorites | Sign in
Project Logo
                
Search
for
Updated Sep 17, 2007 by leidel
Labels: Featured, Phase-Implementation, Phase-Design
ReadMe  
Coordinates Form Field for Django Admin

Introduction

This is the first approach to give admins a nice interface for geographical data. With the included CoordinatesFormField it is possible to add and edit GPS coordinates using one of the popular map services from Google and Yahoo.

Since most of the work is done via Javascript it has a nice fallback with a default TextField. The javascript code is written with generalisation in mind to handle the differences between the map systems.

Howto use CoordinatesField in your own django app

  1. Copy "coordinates_form.html" to a folder where it can be found by the template loader (hint: `TEMPLATE_DIRS` in your settings.py)
  2. Set in your settings.py:
    • `MAP_API` to "google", "yahoo" or "yahooflash"
    • `MAP_API_KEY` to the API key provided by Google or Yahoo
  3. Copy field.py to your django application folder, next to its models.py file
  4. At the top of your applications's models.py file add the following line: from field import CoordinatesField
  5. Change the model of one of the form fields of you model, for example:
  6. gps = models.CharField(maxlength=75) #OLD
    gps = CoordinatesField() #NEW

Howto use it on a testing/development server or locally

Google Maps

Please visit http://www.google.com/apis/maps/signup.html and request a new API key for the domain http://localhost/ or any other valid URL (also e.g. http://192.168.1.1).

Yahoo Maps

Please visit http://search.yahooapis.com/webservices/register_application and request a new API key for the domain http://localhost/ or any other valid URL (also e.g. http://192.168.1.1).


Sign in to add a comment
Hosted by Google Code