Reputation: 2178
I am trying to configure Postgresql 9.1 in Django 1.3 .
Note: I am doing this in Ubuntu 11.10 (oneric). Also I have postgis 1.5 installed to work with Postgresql 9.1
To my best knowledge, I have installed all the dependencies required.
I read the instructions from this blog also.
On doing the following:
python manage.py syncdb
I am getting this error stack.
Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/__init__.py", line 10, in <module>
import django.template.loaders.app_directories
File "/usr/local/lib/python2.7/dist-packages/django/template/loaders/app_directories.py", line 23, in <module>
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
django.core.exceptions.ImproperlyConfigured: ImportError {ProjectName}.{ModuleName}: No module named postgresql.operations
In local_settings.py, I have set engine name as 'django.db.backends.postgresql_psycopg2'.
However after referring to this, I set the engine name to 'django.contrib.gis.db.backends.postgis' , I get the following error stack:
Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/__init__.py", line 10, in <module>
import django.template.loaders.app_directories
File "/usr/local/lib/python2.7/dist-packages/django/template/loaders/app_directories.py", line 21, in <module>
mod = import_module(app)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/jigish/jigbox/dev/mangrove/datawinners/datawinners/../datawinners/accountmanagement/__init__.py", line 3, in <module>
from datawinners.accountmanagement.post_registration_events import ngo_user_created
File "/home/jigish/jigbox/dev/mangrove/datawinners/datawinners/../datawinners/accountmanagement/post_registration_events.py", line 3, in <module>
from datawinners.accountmanagement.models import NGOUserProfile
File "/home/jigish/jigbox/dev/mangrove/datawinners/datawinners/../datawinners/accountmanagement/models.py", line 5, in <module>
from django.db import models
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 78, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 51, 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:
'dummy', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: No module named postgresql.operations
I even ensured, I have the postgis installed (Postgresql-9.1-postgis).
Where am I going wrong? What am I missing?
These are my early days working with Python, Django and Postgresql and Postgis.
Kindly point out any related helpful links on the web. I tried Googling but till now got no success.
Thanks and Regards
Upvotes: 1
Views: 2867
Reputation: 41
I had the same problem. The common source of the error seems to be that psycopg2 isn't properly configured.
I found these posts helpful:
Unable to syncdb in GeoDjango App
Django/Python Beginner: Error when executing python manage.py syncdb - psycopg2 not found
banging my head on setting up and running geodjango
Upvotes: 2
Reputation: 33410
You should use "django.contrib.gis.db.backends.postgis" as backend that's for sure; according to the the official installation guide.
I think you can file a documentation bug there, because the documentation does not mention ubuntu 11.10.
Upvotes: 1