【问题标题】:Specify settings file for Django deployment at GCP App Engine在 GCP App Engine 上为 Django 部署指定设置文件
【发布时间】:2020-07-17 02:41:34
【问题描述】:

在我的 Django 项目中,我的主应用程序(settings.py 文件所在的位置)称为“main/”。

但是,我已经删除了 settings.py 文件,现在我有了一个名为“settings/”的目录,在其中,我有不同的配置文件,例如 development.py、production.py 等。

如何指定 Google Cloud Platform 应将哪个文件用于我的 App Engine 部署?

谢谢。

【问题讨论】:

    标签: django google-app-engine deployment


    【解决方案1】:

    我能够弄清楚这一点。 使用env_variables标签。

    app.yaml

    # [START django_app]
    runtime: python37
    
    handlers:
    # This configures Google App Engine to serve the files in the app's static
    # directory.
    - url: /static
      static_dir: static/
    
    # This handler routes all requests not caught above to your main app. It is
    # required when static routes are defined, but can be omitted (along with
    # the entire handlers section) when there are no static files defined.
    - url: /.*
      script: auto
    
    # Specify settings file
    env_variables:
      DJANGO_SETTINGS_MODULE: "main.settings.gcloud"
    # [END django_app]
    

    【讨论】:

      猜你喜欢
      • 2021-01-06
      • 2021-02-22
      • 1970-01-01
      • 2020-07-10
      • 1970-01-01
      • 1970-01-01
      • 2021-04-25
      • 2013-03-11
      • 2016-12-30
      相关资源
      最近更新 更多