python - django、postgres 8.4、psycopg 2.2.2、python 2.7、mod_wsgi

标签 python django postgresql mod-wsgi psycopg

我已经在本地 django 服务器上安装了 django/postgres 并且工作正常。我正在尝试让 Apache 工作。我已经设置了 mod_wsgi 并且能够获得“Hello World”,并重新启动 Apache。我快到了,但是当我调出 localhost/index.html 时,我收到了这个服务器错误:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 
'django.db.backends.postgresql_psycopg2' isn't an available database 
backend. 
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Try using 
django.db.backends.XXX, where XXX is one of: 
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1]     'dummy', 
'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3' 
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Error was: 
cannot import name utils 

莫非mod_wsgi和psycopg版本不兼容?有没有人尝试过这种类型的设置?

更新 1:

我降级到 2.6、mod_wsgi、psycopg2,但在 apache 日志文件中仍然出现此错误。

Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181] File "C:\Python26\lib\site-packages\django\db\__init__.py", line 77, in [Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181] connection = connections[DEFAULT_DB_ALIAS] [Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181] File "C:\Python26\lib\site-packages\django\db\utils.py", line 91, in getitem [Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181] backend = load_backend(db['ENGINE']) [Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181] File "C:\Python26\lib\site-packages\django\db\utils.py", line 49, in load_backend [Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181] raise ImproperlyConfigured(error_msg) [Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181] TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 'django.db.backends.postgresql_psycopg2' isn't an available database backend. [Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181] Try using django.db.backends.XXX, where XXX is one of: [Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181]
'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3' [Fri Sep 03 12:17:41 2010] [error] [client 97.80.165.181] Error was: cannot import name utils

你知道它可能表示什么吗?

更新 2:

原因在文件 django/db/backends/postgresql_psycopg2/base.py,版本 2.2.2,第 9 行: 从 django.db 导入工具

但我仍然不知道如何解决这个问题。 有一个文件 django/db/utils.py,所以它应该可以工作。毕竟,它适用于开发服务器。但不适用于 Apache + mod_wsgi

最佳答案

也许 this Ticket帮助你:

or whatever it is worth, I have confirmed that if I downgrade python to 2.6 and then likewise downgrade mod_wsgi and psycopg2, Django will work with Postgres on Apache as expected

关于python - django、postgres 8.4、psycopg 2.2.2、python 2.7、mod_wsgi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3633099/

相关文章:

python - Celery .delay() 同步工作,不延迟

sql - 在 pgSQL 上获取内部服务器错误

ruby-on-rails - 使用 ActiveRecord 获取模式的大小

python - Circuit Playground Express 上传问题

Python 子进程命令作为列表而不是字符串

python - 如何在 Matplotlib 中设置颜色条范围?

python - 文档主页,如 Python 文档或 Sphinx 文档?

javascript - AngularJS + Django : URL refresh or direct access not loading correctly

django - 在 Django 的 View 函数中调用函数

sql - 后缀 : How to select the first row of each group?