https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/postgis/#creating-a
-spatial-database-with-postgis-2-0-and-postgresql-9-1
I created my database using the new "CREATE EXTENSION postgis;" method and
then attempted to run tests using the standard, manage.py test, but it
appears that test does not properly add the necessary postgis extensions
and errors with:
{{{
DatabaseError: type "geometry" does not exist
LINE 7: "center" geometry(POINT,3122),
}}}
In addition, I attempted to define the POSTGIS_VERSION in my settings.py
file thinking this might just be undocumented, but even after adding this,
the same error above is still seen.
https://docs.djangoproject.com/en/1.5/ref/contrib/gis/testing/#postgis-
version
I guess the work around is to revert to using the create postgis template
method.
It would be nice if testing was supported when the "CREATE EXTENTSION"
method is used, but if not supported, at least update the docs to mention
testing can't be done when this method is used.
--
Ticket URL: <https://code.djangoproject.com/ticket/20656>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:1>
* component: Uncategorized => GIS
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:2>
Comment (by anonymous):
#19152 was supposed to fix this issue. I have no such setup at hand
currently, but it should be nice to understand why that fix failed
somewhere.
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:3>
Comment (by akaariai):
Did you also run `CREATE EXTENSION postgis_topology;`? I remember that
error message, IIRC the reason was not creating the postgis_topology
extension, or maybe is was having a template database for PostGIS 1.5. The
latter case is easy to check - if you have postgis template, rename it so
that Django won't see it.
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:4>
* component: GIS => Uncategorized
* stage: Accepted => Unreviewed
Comment:
no, "CREATE EXTENSION postgis_topology;" was not run on the initial
database.
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:5>
Comment (by monkut):
just browsed
https://github.com/django/django/commit/fbd1df8e16fc17a5d73f36136298c20b8ec3d618
mentioned in #19152, I don't remember if it's required, but the CREATE
extension statement appears to be missing a ";" (semicolon).
{{{
cursor.execute("CREATE EXTENSION postgis")
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:6>
* status: new => closed
* resolution: => needsinfo
Comment:
Hi Monkut,
I just tried creating a simple project, and my tests run fine.
I've created my database using:
{{{
$ createdb mydb
$ psql mydb
psql (9.2.2)
Type "help" for help.
mydb=# CREATE EXTENSION postgis;
CREATE EXTENSION
}}}
I've tested using `manage.py test myapp` on Django 1.5 and Django Trunk
(commit 99b467f272da9). For future reference, my Postgresql version was
9.2.2 and POSTGIS was 2.0.2.
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:7>
* component: Uncategorized => GIS
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:8>
* component: GIS => Uncategorized
Comment:
ok, it's probably an error on my part. I've already migrated back to the
template method, but if I hit the problem again I'll try to get more
details.
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:9>
* cc: flavio.curella@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:10>
* version: 1.5 => 1.4-beta-1
Comment:
<a href=http://silvertoncustomhomes.com/lib/#ybc3o>buy soma</a> generic
form of soma - www.soma bras
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:11>
* version: 1.5 => 1.4-rc-1
Comment:
<a href=http://reglenna.com/doc/#kgx>external link</a> ativan 2mg tablet -
side effects of ativan during pregnancy
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:11>
* version: 1.5 => 1.7-alpha-1
Comment:
<a href=http://reglenna.com/doc/#tepu9r>More about the author</a> ativan
1.5 mg - ativan withdrawal time period
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:11>
* version: 1.5 => 1.5-rc-1
Comment:
<a href=http://www.andresramirezgaviria.com/file/#x07mph>generic
provigil</a> buy provigil online uk - provigil daily dosage
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:11>
Comment (by timgraham):
I ran into this problem and fixed it by dropping the PostGIS template as
Anssi suggested in comment 4:
{{{
postgres=# UPDATE pg_database SET datistemplate='false' WHERE
datname='template_postgis';
UPDATE 1
postgres=# DROP DATABASE template_postgis;
DROP DATABASE
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20656#comment:11>