1

Django チュートリアルの「mysite/poll」アプリをローカルで実行しており、GAE にデプロイしようとしています。wsgi.py と admin.py で DJANGO_SETTINGS_MODULE を次のように定義しました。

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

これは展開のトレースバックです:

Traceback (most recent call last):
  File "/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py",      line 196, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
      File        "/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 255, in   _LoadHandler
    handler = __import__(path[0])
  File "/base/data/home/apps/s~ceemee11111/1.365096182895980177/admin.py", line 1, in <module>
from django.contrib import admin
  File "/python27_runtime/python27_lib/versions/third_party/django-1.4/django/contrib/admin/__init__.py", line 3, in <module>
    from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
  File "/python27_runtime/python27_lib/versions/third_party/django-1.4/django/contrib/admin/helpers.py", line 2, in <module>
    from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
      File "/python27_runtime/python27_lib/versions/third_party/django-          1.4/django/contrib/admin/util.py", line 1, in <module>
    from django.db import models
  File "/python27_runtime/python27_lib/versions/third_party/django-1.4/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/python27_runtime/python27_lib/versions/third_party/django-1.4/django/utils/functional.py", line 184, in inner
self._setup()
  File "/python27_runtime/python27_lib/versions/third_party/django-1.4/django/conf/__init__.py", line 40, in _setup
    raise ImportError("Settings cannot be imported, because environment variable %s is        undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable             DJANGO_SETTINGS_MODULE is undefined.

DJANGO_SETTINGS_MODULE がまだ定義されていないのはなぜですか

ありがとうダン

4

2 に答える 2

1

https://developers.google.com/appengine/docs/python/tools/libraries27#django

追加を試すこともできます

env_variables:
  DJANGO_SETTINGS_MODULE: 'myapp.settings'

app.yaml で

于 2013-02-06T11:01:51.553 に答える
1

代わりにこれを試してください:

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
于 2013-02-05T20:32:33.007 に答える