Database Reference
In-Depth Information
country_shp = '../
TM_WORLD_BORDERS-0.3.shp'
country_lm = LayerMapping(Country,
country_shp, country_mapping,
transform=False,
encoding='iso-8859-1')
country_lm.save(verbose=True,
progress=True)
20. Enter the Python Django shell and run the utils.py script. Then, check
whether or not the countries have been correctly inserted in the sight-
ings_country table in your PostgreSQL database:
(chp09-env)$ python manage.py shell
>>> from sightings import load_countries
Saved: Antigua and Barbuda
Saved: Algeria
Saved: Azerbaijan
...
Saved: Taiwan
Now, you should see the countries in the administrative interface. Try to browse
some of the countries at http://localhost:8000/admin/sightings/coun-
try/ .
How it works...
Inthisrecipe,youhaveseenhowquickandefficientitistoassembleabackoffice
application using Django , one of the most popular Python web frameworks; this
is thanks to its object-relational mapper, which automatically created the database
tablesneededbyyourapplicationandanautomaticAPItomanage(insert,update,
and delete) and query the entities without using SQL.
Thankstothe GeoDjango library,twooftheapplicationmodels,CountyandSight-
ing, have been geo-enabled with their introduction in the database tables of geo-
metric PostGIS fields.
Search WWH ::




Custom Search