【发布时间】:2016-02-04 06:56:13
【问题描述】:
我有一个 Django 应用程序,它呈现一些网页,让人们向我的数据库提交一些信息。项目结构如下:
--wun/
--manage.py
--templates/uploader/
--some_html_files.html
--static/uploader/
--css_files.css
--wun/
--settings.py
--urls.py
--wsgi.py
--uploader/
--app_files.py
所以项目名为'wun',我的应用程序名为'uploader'。结构是典型的 Django。
在本地 Django 的开发服务器上运行它没有问题,但是当将它部署到 GAE 时,我在访问的每个 url 端点上都会得到 404 Not Found。我在 Django 设置中打开了DBUG,但没有其他信息。我可以在 GAE 的日志中看到访问过的端点。
我想也许 GAE 找不到静态文件和模板?我在 Django 中有以下设置:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR,os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
STATIC_URL = '/static/'
在 App 引擎上:
handlers:
- url: /static
static_dir: static
- url: /static/uploader
static_dir: /static/uploader
- url: .*
script: wun.wsgi.application
但我不认为这里使用前两个 url,因为我不直接提供页面。所有页面都由模板中的 Django 视图呈现。
【问题讨论】:
标签: python django google-app-engine