我正在尝试在Django 1.3中配置Postgresql 9.1。
注意:我在Ubuntu 11.10(oneric)中这样做。我也安装了postgis 1.5以与Postgresql 9.1一起使用
据我所知,我已经安装了所有必需的依赖项 我也阅读了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 :(得分:2)
我遇到了同样的问题。错误的常见来源似乎是没有正确配置psycopg2。
我发现这些帖子很有用:
Unable to syncdb in GeoDjango App
Django/Python Beginner: Error when executing python manage.py syncdb - psycopg2 not found
答案 1 :(得分:1)
你应该使用“django.contrib.gis.db.backends.postgis”作为后端,这是肯定的;根据{{3}}。
我认为你可以在那里提交文档错误,因为文档没有提到ubuntu 11.10。