...
Follow the instructions at http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS15Ubuntu1004src to retrieve, build and install version 1.5 of PostGIS.
...
Build The Template
Ignore the instructions on that page. Instead:
...
Code Block |
---|
createdb -E UTF-8 --locale=en_US.UTF-8 template_postgis -T template0
createlang plpgsql template_postgis
psql -d template_postgis -c "UPDATE pg_database SET datistemplate=true WHERE datname='template_postgis'"
psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis.sql
psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql
psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis_comments.sql
|
Exit the postgres user:
Code Block |
---|
exit
exit
|
Note: in these instructions, the template name is template_postgis
You can choose any template name you like, but you will need to use your particular template name where appropriate when creating a database from the template.
Grant necessary permissions to new tables
Note |
---|
I'm not yet sure if this step can be done here, or if it has to be done after the database is created from the template. |
Some of the table created by PostGIS do not have correct permissions for your user. To grant these permissions:
Code Block |
---|
psql oercommons_db
GRANT SELECT ON geometry_columns TO oercommons_user;
GRANT DELETE ON geometry_columns TO oercommons_user;
GRANT INSERT ON geometry_columns TO oercommons_user;
GRANT SELECT ON spatial_ref_sys TO oercommons_user;
\q
|
Note that these commands assume your database user is oercommons_user
. If you are using a different user name (as specified in your project/development.py
file), you'll have to adjust these commands accordingly.
Exit the postgres user:
Code Block |
---|
exit
exit
|
Update development.py
In your project/development.py
file, update the "ENGINE" of your default database definition:
Code Block | ||||
---|---|---|---|---|
| ||||
DATABASES = {
'default': {
'NAME': 'oercommons_db',
'ENGINE': 'django.contrib.gis.db.backends.postgis', # <== Update this value
'USER': '',
'PASSWORD': ''
}
}
|