1

我正在尝试将我的 django-app 部署到 Google App Engine,但是当我运行 manage.py syncdb 时不断收到此错误。

Traceback (most recent call last):


File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\utils\imp
ortlib.py", line 35, in import_module
    __import__(name)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\commands\syncdb.py", line 8, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_
signal
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\sql.py", line 6, in <module>
    from django.db import models
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\db\__init
__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\db\__init
__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\db\utils.
py", line 92, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\db\utils.
py", line 44, in load_backend
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'google.appengine.ext.django.backen
ds.rdbms' isn't an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
    'dummy', 'mysql', 'oracle', 'postgresql_psycopg2', 'rdbms', 'sqlite3'
Error was: No module named django.backends.rdbms.base

我确保这些都包含在我的 pythonpath 中:-

C:\ProgramFiles\Google\google_appengine;C:\ProgramFiles\Google\google_appengine\lib\django_1_4

但我仍然得到名为 django.backends.rdbms.base 的 No modules。

这是我的settings.py

# Django settings for firstproject project.

import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__)) + os.sep

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

#production =  True

import os

SETTINGS_MODE='prod'

if (os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine') or
    os.getenv('SETTINGS_MODE') == 'prod'):

    DATABASES = {
    'default': {
        'ENGINE': 'google.appengine.ext.django.backends.rdbms',
        'INSTANCE': 'd73292536:instance1',
        'NAME': 'example',
    }
}

else:

        DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
            'NAME': 'third',                      # Or path to database file if using sqlite3.
            'USER': 'root',                      # Not used with sqlite3.
            'PASSWORD': '',                  # Not used with sqlite3.
            'HOST': '127.0.0.1',                      # Set to empty string for localhost. Not used with sqlite3.
            'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
        }
    }

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Eastern'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '' 

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative path
    "C:\Users\sheila\Desktop\Templates\static",
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '+iiq+84-xm_pmxsbwz18#*n2hht$5f9o_m6d8spt2buhxxl0m='

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'google.appengine.ext.ndb.django_middleware.NdbDjangoMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'firstproject.wsgi.application'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.

    "C:\\Users\\sheila\\Desktop\\Templates\\polls"
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    #'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'polls',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}
4

4 回答 4

0

一个问题是,您的设置文件错误。似乎在您的设置文件中,您设置了
'ENGINE': 'google.appengine.ext.django.backends.rdbms' . 导入 os if (os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine') 或 os.getenv('SETTINGS_MODE') == 'prod'):

于 2013-01-23T18:27:58.517 回答
0

在您的问题中,您提到您将以下内容添加到您的 PYTHONPATH

C:\ProgramFiles\Google\google_appengine;C:\ProgramFiles\Google\google_appengine\lib\django_1_4

该路径是错误的,因为“程序文件”中有一个空格。因此,您的运行时没有找到google.appengine.ext.django.backends.rdbms.

于 2013-01-24T05:34:30.367 回答
0

我相信这是为您提供的,您不必添加文件,请参见此处:3rd party library

你的 app.yaml 中有这个吗?

libraries:
- name: django
  version: "1.4"

这也可能是相关的:

要将 Django 与 NDB 存储 API 一起使用,请将“google.appengine.ext.ndb.django_middleware.NdbDjangoMiddleware”添加到 Django settings.py 文件的 MIDDLEWARE_CLASSES 条目中。

与上面相同的链接。

于 2013-01-23T17:08:49.987 回答
0

我的问题可能重复。有关部署的更多信息,请参阅接受的答案和链接的后续问题。

我最终通过使用数据库定义中的建议if: else:子句对部署进行了排序。SETTINGS.PY

于 2013-01-24T00:53:07.643 回答