2012-02-20 108 views
1


我想在Django 1.3中配置Postgresql 9.1。
注意:我在Ubuntu 11.10(oneric)中這樣做。我也安裝postgis 1.5與PostgreSQL 9.1配合使用
爲Django設置Postgresql 9.1數據庫11.10

據我所知,我安裝了所有需要的依賴關係。
我從this博客也閱讀說明。

做好以下工作:

python manage.py syncdb 

我收到此錯誤堆棧。

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 

在local_settings.py,我已經設置引擎名稱爲 'django.db.backends.postgresql_psycopg2'。

但是參照this後,我設置的引擎名稱爲「django.contrib.gis.db.backends.postgis」,我碰到下面的錯誤堆棧:

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 

我甚至保證,我有安裝postgis(Postgresql-9.1-postgis)。

我哪裏錯了?我錯過了什麼? 這些是我在Python,Django和Postgresql以及Postgis的早期工作。
請在網上指出任何相關的有用鏈接。我嘗試了谷歌搜索,但直到現在沒有成功。

感謝和問候

+0

「據我所知,我已經安裝了所有必需的依賴。」請詳細說明一下。你安裝了psycopg2嗎?你可以發佈你已經安裝版本的軟件包列表(apt和python)嗎? TYIA – jpic 2012-02-20 10:12:47

+0

這已經在我的問題中提到的鏈接中提到過。仍在重複我的自我。 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。 – 2012-02-20 10:21:51

+0

你在說什麼名單?我關於psycopg2安裝的問題怎麼樣? – jpic 2012-02-20 10:25:53

回答

1

您應該使用「django.contrib.gis.db.backends.postgis」作爲後端這是肯定的;根據the official installation guide

我想你可以在那裏提交文檔錯誤,因爲文檔沒有提到ubuntu 11.10。

+0

我遵循安裝指南。但是,安裝指南適用於Ubuntu 10.10和更低版本的用戶。 我也想讓你知道,正常的安裝步驟工作正常,直到Ubuntu 11.04。因此我正在爲11.10而努力。 – 2012-02-20 10:38:35