我在设置Django 1.5以通过dev_appserver.py而不是manage.py runserver运行时遇到了一些困难 .

项目目录是这样的:

  • env

  • myproject

  • manage.py

  • myproject

  • init,settings,urls,wsgi(.py)

我尝试了以下两种方法来使用App Engines appserver:

app.yaml中:

application: appname
version: 1
runtime: python27
api_version: 1
threadsafe: true

libraries:
- name: django
  version: "1.5"

builtins:
- django_wsgi: on

正如本教程所建议的https://cloud.google.com/appengine/docs/python/cloud-sql/django

设置本地服务器时不会产生任何错误,但是当我访问给定的链接时,我收到此错误:

RuntimeError: django must be included in the "libraries:" clause of your app.yaml file when using the django_wsgi builtin.

接下来我以稍微不同的方式尝试了它 . 使用app.yaml

application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: .*
  script: main.application

libraries:
- name: django
  version: "1.5"

和main.py这样:

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

这会产生以下错误:

File "C:\Users\Mello\AppEngine\02\myproject\main.py", line 4, in module>
import django.core.handlers.wsgi
ImportError: No module named django.core.handlers.wsgi

即使我跑了

>>>import django.core.handlers.wsgi
>>>

在同一个虚拟环境中,它运行正常 .


任何人都有任何建议指出我正确的方向来解决这个问题?

谢谢