我正在使用带有 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
但是,当传入的 url 为myapp.appspot.com/helloworld/*
时,页面将被重定向到登录页面。并且日志显示/_ah/start
404。
我在Appengine 模块中看到了类似的问题:Routing with dispatch.yaml not working which modifyed wsgi config with webapp2 framework。
这是我的 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.yaml
和appcfg update_dispatch .
上传这些设置。
如何使用 django 框架正确导入这个 helloworld 模块?
谢谢你。