问题
I am trying to enable testing on a brand new Django app. It has to run geometry tests. My Postgres installation in Postgres.app (with Postgis 2), my default database runs just fine (no problems with Django app syncing, creating, etc), but when I run
manage.py test
I get an error:
django.db.utils.ProgrammingError: type "geography" does not exist LINE 4: "geom" geography(GEOMETRY,4326) NOT NULL
Full errors: https://gist.github.com/dyve/11dcd455aa5a25628773
I know that Django creates a Postgres DB for testing. I'm suspecting that it does not correctly enable the PostGIS extension(s) on the test DB.
Much appreciated if anyone here can help me get testing.
回答1:
Asking the question is answering it ...
I looked into the Django source, and saw it tests for the existence of template_postgis
. If found, it works for Postgis < 2.0. If not found, it works for Postgis >= 2.
And lo and behold, a relic template_postgis was present in my DB. I renamed it (just keeping it until I'm sure I don't need it for some other project), and the test worked fine.
来源:https://stackoverflow.com/questions/24730189/testing-a-geodjango-app-with-a-postgis-database