2017-11-11 135 views
0

我在Google控制檯上部署開發的django應用程序時遇到問題。 首先,它將應用程序的所有文件重命名爲一些隨機名稱。另外,當我嘗試訪問網站.appspot.com時,出現內部錯誤。我們如何在google雲上部署django應用?

已創建app.yaml文件:

# [START runtime] 
runtime: python27 
entrypoint: gunicorn -b :$PORT mysite.wsgi 
threadsafe: true 
# [END runtime] 

handlers: 
- url: /static 
    static_dir: website/static 

- url: /.* 
    script: main.application 

libraries: 

- name: django 
    version: 1.11 

也創造了appengine_cofig.py文件:

# Copyright 2015 Google Inc. All rights reserved. 
# 
# Licensed under the Apache License, Version 2.0 (the "License"); 
# you may not use this file except in compliance with the License. 
# You may obtain a copy of the License at 
# 
#  http://www.apache.org/licenses/LICENSE-2.0 
# 
# Unless required by applicable law or agreed to in writing, software 
# distributed under the License is distributed on an "AS IS" BASIS, 
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
# See the License for the specific language governing permissions and 
# limitations under the License. 

# [START vendor] 
from google.appengine.ext import vendor 

vendor.add('lib') 
# [END vendor] 

感謝提前的幫助....

+0

如果錯誤出現在您的代碼中,那麼請求日誌應該包含堆棧跟蹤。請找到它並將其添加到您的問題;請包括您正在訪問的視圖的視圖代碼。否則這個問題是無法回答的。 – snakecharmerb

+2

沒有足夠的信息在您的文章真正能夠幫助你很多。突出的一點是,您將靈活環境的語法與標準環境相結合(「入口點」僅適用於靈活環境)。 – BrettJ

+0

**從初學者的角度來看** ...我怎樣才能讓我的django網站上運行谷歌應用程序引擎? –

回答

0

作爲一個完整的初學者,我會建議遵循這裏的谷歌文檔(https://cloud.google.com/python/django/appengine)一步一步注意到的是:

  1. Django的默認數據庫是sqlite3的,你必須將其更改爲MySQL和建議您在創建Django應用程序的非常beggining做到這一點。我建議您在此YouTube視頻中使用以下說明(https://www.youtube.com/watch?v=s16p32pndK0
  2. 您的app.yaml文件應該看起來如此;

runtime: python27 
 
api_version: 1 
 
threadsafe: yes 
 

 
handlers: 
 
- url: /static 
 
    static_dir: static/ 
 
    application_readable: True 
 
- url: .* 
 
    script: yourapplication.wsgi.application 
 

 
# Only pure Python libraries can be vendored 
 
# Python libraries that use C extensions can 
 
# only be included if they are part of the App Engine SDK 
 
# Using Third Party Libraries: https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27 
 
libraries: 
 
- name: MySQLdb 
 
    version: 1.2.5 
 
- name: django 
 
    version: "1.11" 
 
- name: ssl 
 
    version: latest 
 
# [END django_app] 
 
    
 
# Google App Engine limits application deployments to 10,000 uploaded files per 
 
# version. The skip_files section allows us to skip virtual environment files 
 
# to meet this requirement. The first 5 are the default regular expressions to 
 
# skip, while the last one is for all env/ files. 
 
skip_files: 
 
- ^(.*/)?#.*#$ 
 
- ^(.*/)?.*~$ 
 
- ^(.*/)?.*\.py[co]$ 
 
- ^(.*/)?.*/RCS/.*$ 
 
- ^(.*/)?\..*$ 
 
- ^env/.*$

我也是一個初學者,我剛纔已經成功地部署我的應用程序到GAE,一切順利。

+0

感謝您的幫助我已經部署在GAE 我的應用程序也已上載的git https://github.com/abhisheklokare/Website-using-Python-Django-Framework項目 做檢查吧... –