I am trying to upgrade a Django 1.6.2 application to 1.7.10. I am running PostgreSQL on my Mac using Postgres.app version 9.3.4, which runs PostgreSQL 9.3.4 and PostGIS 2.1.1. The problem I am facing is that when I run the new "makemigrations" command, I get the following error (the entire stacktrace element is at the bottom):
django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis.db.backends.postgis' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: u'base', u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3' Error was: cannot import name BaseSpatialOperations
Here are the relevant settings:
# conf/settings/base.py DATABASES = { 'default': { 'ENGINE' : 'django.contrib.gis.db.backends.postgis', 'NAME' : 'geodb', 'USER' : 'geo', 'PASSWORD': 'geopassword',
I used the same DATABASE ENGINE installation in my Django 1.6.2 application without any problems. While studying this, some other developers forgot to install psycopg2 in their virtual environment, but I have version 2.6.1 installed in mine. I used version 2.5.2 with Django 1.6.2, but if I go back to psycopg2 for this version, I will still get this error. I read all the psycopg2 release notes between these two versions and did not see anything that could cause this problem.
The GeoDjango tutorial for Django 1.7 also uses this postgis engine mechanism, so it doesn't look deprecated, and in Django 1.7 there is nothing suitable that indicates that this could be a problem.
I also created a test version of the GeoDjango tutorial mentioned above, and if I run the makemigrations command on it, I get the same error.
Finally, I did a web search and don't see articles that discuss this issue with migration / database. Does anyone see what is wrong?
Thanks!
# Full stacktrace Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute django.setup() File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/__init__.py", line 21, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/contrib/auth/models.py", line 40, in <module> class Permission(models.Model): File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/db/models/base.py", line 122, in __new__ new_class.add_to_class('_meta', Options(meta, **kwargs)) File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/db/models/base.py", line 297, in add_to_class value.contribute_to_class(cls, name) File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/db/models/options.py", line 166, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/db/__init__.py", line 40, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/db/utils.py", line 242, in __getitem__ backend = load_backend(db['ENGINE']) File "/Users/me/venv/dj_17/lib/python2.7/site-packages/django/db/utils.py", line 126, in load_backend raise ImproperlyConfigured(error_msg) django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis.db.backends.postgis' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: u'base', u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3' Error was: cannot import name BaseSpatialOperations