Python 模块在带有django框架的gae中不工作
我正在使用带有django框架的google应用程序引擎 我有两个模块:default和helloworld app.yaml如下所示:Python 模块在带有django框架的gae中不工作,python,django,google-app-engine,google-app-engine-python,Python,Django,Google App Engine,Google App Engine Python,我正在使用带有django框架的google应用程序引擎 我有两个模块: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 -
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
application: myapp
dispatch:
- url: "*/helloworld/*"
module: helloworld
我希望所有的myapp.appspot.com/helloworld/*
都将路由到helloworld模块
dispatch.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
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/*时,页面将重定向到登录页面。日志显示/\u ah/start
404
我看到过类似的问题,其中使用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.yaml
和appcfg update\u dispatch.
上传这些设置
如何使用django框架正确导入这个helloworld模块
谢谢。发布您的
分派的内容。yaml
您的helloworld
模块是否有与helloworld/*
匹配的处理程序?不,实际上,如果即将到来的url由分派器路由,我不理解模块中的处理程序是如何工作的。假设它是一个独立的应用程序。它需要注册一个与/helloworld/
匹配的视图才能响应该请求。如果没有,您将在myapp.url中获得404./helloworld/并将其路由到helloworld.url。helloworld不仅是一个模块,也是我基于django的项目中的一个应用程序。