1

我按照这里的步骤https://developers.google.com/cloud-sql/docs/django并在 django 1.3.1 上运行良好。现在到 Django 1.4 并给出了一个有趣的堆栈跟踪。我将在此处粘贴消息的相关部分

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/dumb906/woody/py/mdlr/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/home/dumb906/woody/py/mdlr/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/dumb906/woody/py/mdlr/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/dumb906/woody/py/mdlr/django/core/management/__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/home/dumb906/woody/py/mdlr/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/dumb906/woody/py/mdlr/django/core/management/commands/test.py", line 7, in <module>
    from django.test.utils import get_runner
  File "/home/dumb906/woody/py/mdlr/django/test/__init__.py", line 5, in <module>
    from django.test.client import Client, RequestFactory
  File "/home/dumb906/woody/py/mdlr/django/test/client.py", line 21, in <module>
    from django.test import signals
  File "/home/dumb906/woody/py/mdlr/django/test/signals.py", line 2, in <module>
    from django.db import connections
  File "/home/dumb906/woody/py/mdlr/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "/home/dumb906/woody/py/mdlr/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/home/dumb906/woody/py/mdlr/django/db/utils.py", line 92, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/home/dumb906/woody/py/mdlr/django/db/utils.py", line 44, in load_backend
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'google.appengine.ext.django.backends.rdbms' 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: cannot import name Thing2Literal

有什么帮助吗?有人说需要编译http://django-irc-logs.com/2012/mar/27/

4

2 回答 2

3

我遇到过同样的问题。由于问题在于从 django/db/backends/mysql/base.py 导入由 adapt_datetime_with_timezone_support 函数使用的 Thing2Literal 并根据此: https ://code.djangoproject.com/changeset/17596/django/trunk/django/ db/backends/mysql/base.py这仅对绕过模型层并与原始 sql 一起使用的日期时间对象很重要。所以我决定这对我来说并不重要,我弄乱了我的 django/db/backends/mysql/base.py:注释掉导致麻烦的代码(导入 Thing2Literal、adapt_datetime_with_timezone_support 函数和调用该函数的第 83 行)的当然,我将我以这种方式定制的 django 1.4 与我的项目一起上传到 appengine 并且它可以工作。

如果我根本不使用原始 sql,我将感谢那些更好地了解 django 内部结构的人的反馈,无论我所做的一切是否正常。

于 2012-05-07T21:12:38.823 回答
-2

正如您在链接的文档中看到的那样,Google App Engine 仅支持 Django 版本 1.3(实际上是 1.3.1)。

于 2012-04-23T12:04:02.590 回答