模块在使用django框架的gae中不起作用

时间:2015-10-16 12:59:07

标签: python django google-app-engine google-app-engine-python

我正在使用带有django框架的谷歌应用引擎。

我有两个模块:default和helloworld

app.yaml如下:

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

handlers:
- url: /favicon.ico
  static_files: static/favicon.ico
  upload: static/favicon.ico
- url: /robots.txt
  static_files: static/robots.txt
  upload: static/robots.txt
- url: /static
  static_dir: static
- url: /_ah/queue/deferred
  script: google.appengine.ext.deferred.deferred.application
  login: admin
- url: /.*
  script: myapp.wsgi.application
  secure: always

我希望所有myapp.appspot.com/helloworld/*都被路由到helloworld模块。

dispatch.yaml如下:

application: myapp
dispatch:
- url: "*/helloworld/*"
  module: helloworld

这里是helloworld.yaml:

application: myapp
module: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: true
instance_class: B2
basic_scaling:
  max_instances: 3

handlers:
- url: /favicon.ico
  static_files: static/favicon.ico
  upload: static/favicon.ico
- url: /robots.txt
  static_files: static/robots.txt
  upload: static/robots.txt
- url: /static
  static_dir: static
- url: /_ah/queue/deferred
  script: google.appengine.ext.deferred.deferred.application
  login: admin
- url: /.*
  script: myapp.wsgi.application
  secure: always

但是,当即将到来的网址为myapp.appspot.com/helloworld/*时,该网页将被重定向到登录页面。并且日志显示/_ah/start 404。

我在Appengine module: Routing with dispatch.yaml not working中看到了类似的问题,它用webapp2框架修改了wsgi配置。

这是我的wsgi.py

import os, sys
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'libs'))

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

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

我使用appcfg update app.yaml helloworld.yamlappcfg update_dispatch .上传这些设置。

如何使用django框架正确导入此helloworld模块?

谢谢。

0 个答案:

没有答案