2017-11-11 134 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项目 做检查吧... –