【问题标题】:Django on GAE: Resource could not be foundGAE 上的 Django:找不到资源
【发布时间】: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


    【解决方案1】:

    事实证明,GoogleAppEngineLauncher 自动在我的项目文件夹下创建了另一个文件夹,并且它正在使用那里没有任何内容的应用程序设置。所以当访问服务器时,实际上并没有运行 Django 应用程序,它只是一个空服务器。

    【讨论】:

      猜你喜欢
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      • 2015-05-03
      • 2013-01-03
      相关资源
      最近更新 更多