GeoDjango has some great documentation, but there are still some areas that are missing, especially some simple examples for Django noobs.

First, check which branch you're using. As of 2/24/08, The gis branch in the main django svn lags a bit behind some of the work being done on the gis-newforms branch, available at select mercurial repositories near you (find out which to use by asking the developers on #geodjango). This example is for use with the latest gis-newforms.

Next, follow the excellent official install instructions. If you already have a box with all the software described here, you just need to softlink your site-packages/django to the gis-newforms/django that you downloaded. Now, you should have GeoDjango available (see their install instructions page above to test this), and so we can start building a basic site.

The example site we'll build will be an app with Counties (which we will import from a shapefile), and Locations, which will reside within a county. When we add a location, it should automatically get assigned an appropriate County. We will create a basic kml view of the locations for display in Google Earth, and an OpenLayer? based map view.

create the site and app

django-admin.py startproject geosite
cd geosite
python manage.py createapp geoapp

next, let's get us some URL's, by modifying urls.py:

#urls.py



and make some models:

#geoapp/models.py

and, some views: #geoapp/views.py


finally, the templates:

#geoapp/templates/placemarks.kml


and

#geoapp/templates/base.kml