Migrations not working with Postgis

February 21, 2016

./manage.py migrate was giving me the following error:

django.db.utils.OperationalError: could not open extension control file "/usr/share/postgresql/9.1/extension/postgis.control":
No such file or directory

I'm on Debian, and most of the solutions suggest installing a scripts package that isn't there.

There's a workaround for this, which is to add the following to settings.py:

POSTGIS_TEMPLATE = 'my_database_name'

References

http://stackoverflow.com/questions/32232380/how-can-i-enable-geodjango-on-an-already-existing-postgres-database-on-webfactio