Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

geodjango syncdb errors. From geodjango tutorial

I have followed the geodjango installation(windows XP) and tutorial to perfection I am running django 1.2 When I get to syncdb and run I receive the following.

    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured:'django.db.backends.postgis' isn
an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
    'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3
Error was: No module named postgis.base

I tried changing to 'django.db.backends.postgresql_psycopg2' as an alternative But then I receive this response:

AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'

When I try posgresql:

    **raise ImproperlyConfigured("Error loading psycopg module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: No mo
dule named psycopg**

Is it not supposed to be postgis which I successful downloaded and installed? why isn’t it working? I am new and I am trying to learn so any help would be greatly appreciated.

like image 764
Stu Avatar asked Aug 25 '10 15:08

Stu


2 Answers

The problem is, in settings.py

'django.db.backends.postgis'

it is supposed to be

django.contrib.gis.db.backends.postgis

that should do it.

like image 106
Stu Avatar answered Oct 14 '22 21:10

Stu


I experienced this same error on Mac OS X 10.6 after I followed the instructions on the geodjango site and installed packages using Homebrew. Apparently, the Geodjango documentation gave some incorrect/outdated instructions about how to install it. To make Geodjango work, I followed several steps:

  1. Right now, GeoDjango 1.4 does not play nice with PostGIS 2.0 (which is the version Homebrew installed when I followed the instructions in the GeoDjango documentation). So, I needed to install PostGIS 1.5. I did this using the following Terminal commands (for this to work, you must have Homebrew installed):

    brew tap homebrew/versions
    brew install postgis15
    brew untap homebrew/versions
    
  2. PostGIS 1.5 doesn't play nice with PostGreSQL 9.2 (which is the version Homebrew installed when I followed the Geodjango documentation's instructions). So, I installed PostGreSQL 9.1. I forget exactly what Homebrew commands I used to install PostGreSQL 9.1, but they should be similar to the previous step.

  3. In my case the prior steps weren't sufficient to get Geodjango operational. When I tried to run 'syncdb' in Django again, I discovered a new error in Terminal:

    django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: 
    No module named psycopg 
    
  4. I initially thought my copy of psycopg2 and PostgreSQL9.1 were not on my PYHTONPATH, so I added them. I also fiddled around to make sure django was running PostgreSQL 9.1 instead of 9.2. I used 'initdb /usr/local/var/postgres'.

  5. Then I needed to do some database configuration. I set up a template in PostGIS and set up a "role" (/user) for the database. To do this, I followed the instructions in the Geodjango documentation. I received numerous errors, but Googled them and found solutions pretty easily.

  6. Then GeoDjango started working properly!

This source was the most helpful one I found and links to other helpful urls that cover some of these issues in more detail: http://pragmaticstartup.wordpress.com/2012/09/26/installing-django-postgis-postgres-on-os-x-version-hell/

like image 22
Brian Avatar answered Oct 14 '22 21:10

Brian