Database Reference
In-Depth Information
gismodels.PointField(srid=4326)
objects = gismodels.GeoManager()
def __unicode__(self):
return '%s' % (self.date)
class Meta:
ordering = ['date']
9. Eachmodelwillbecomeatableinthedatabasewiththecorrespondingfields
defined using the models and gismodels class. Note that the geometry
variableinthe county and sighting modelswillbecomethe MultiPoly-
gon and Point PostGIS geometry columns, thanks to the GeoDjango lib-
rary. Now, we synchronize the database by executingthe following code:
(chp09-env)$ python manage.py syncdb
Creating tables ...
Creating table sightings_animal
Creating table sightings_sighting
Creating table sightings_country
10. Now,foreachmodelin models.py ,aPostgreSQLtableshouldhavebeen
created. Check whether or not your PostgreSQL database effectively con-
tainsthethreetablescreatedintheprecedingcommandsusingyourfavorite
client (that is, psql or pgAdmin ), and whether or not the sight-
ings_sighting and sightings_country tables contain PostGIS geo-
metric fields.
11. Createan admin.py fileunder chp09/wildlife/sightings andaddthe
followingcodetoit.Theclassesinthisfilewilldefineandcustomizethebe-
havior of the Django admin site when browsing the application models or
tables(fieldstodisplay,fieldstobeusedtofilterrecords,andfieldstoorder
records). Create the file containing the following code:
from django.contrib import admin
from django.contrib.gis.admin import
GeoModelAdmin
from models import Country, Animal,
Sighting
Search WWH ::




Custom Search