1


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

6
  • "To my best knowledge, I have installed all the dependencies required.". Please, elaborate on that. Have you installed psycopg2 ? Can you post the list of packages (apt and python) which you have installed with versions ? TYIA Commented Feb 20, 2012 at 10:12
  • This is already mentioned in the link mentioned in my question. Still repeating my self. gdal-bin binutils libgeos-3.2.2 libgeos-c1 libgeos-dev libgdal1-1.8.0 libgdal1-dev libxml2 libxml2-dev libxml2-dev proj psycopg2 == 2.4.1. Commented Feb 20, 2012 at 10:21
  • What list are you talking about ? What about my questions regarding your psycopg2 installation ? Commented Feb 20, 2012 at 10:25
  • Postgresql 9.1 Postgresql-9.1-postgis django 1.3 Commented Feb 20, 2012 at 10:28
  • Did you add django.contrib.gis to INSTALLED_APPS ? Commented Feb 20, 2012 at 10:39

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

I have followed the installation guide. However, the installation guide is meant for Ubuntu 10.10 and lower Users. I also want to let you know that the normal installation steps works fine till Ubuntu 11.04. Hence I was trying it for 11.10.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.