Testing a GeoDjango app with a PostGIS database

余生长醉 提交于 2019-12-31 03:07:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!