From 429ce1810fc26d838dc90701cf14fd36bff91665 Mon Sep 17 00:00:00 2001 From: Ryan Matsumoto Date: Mon, 12 Dec 2016 18:54:07 -0800 Subject: [PATCH 1/7] Updated GAE Standard Django App for CloudSQL v2 and moved it to repo --- appengine/standard/django/.gitignore | 49 +++++++ appengine/standard/django/CONTRIBUTING.md | 35 +++++ appengine/standard/django/LICENSE | 27 ++++ appengine/standard/django/README.md | 20 +++ appengine/standard/django/app.yaml | 43 ++++++ appengine/standard/django/appengine_config.py | 18 +++ appengine/standard/django/manage.py | 24 ++++ appengine/standard/django/mysite/__init__.py | 0 appengine/standard/django/mysite/settings.py | 136 ++++++++++++++++++ appengine/standard/django/mysite/urls.py | 23 +++ appengine/standard/django/mysite/wsgi.py | 29 ++++ appengine/standard/django/polls/__init__.py | 0 appengine/standard/django/polls/admin.py | 20 +++ appengine/standard/django/polls/models.py | 26 ++++ appengine/standard/django/polls/tests.py | 20 +++ appengine/standard/django/polls/views.py | 19 +++ .../standard/django/requirements-vendor.txt | 1 + appengine/standard/django/requirements.txt | 5 + 18 files changed, 495 insertions(+) create mode 100644 appengine/standard/django/.gitignore create mode 100644 appengine/standard/django/CONTRIBUTING.md create mode 100644 appengine/standard/django/LICENSE create mode 100644 appengine/standard/django/README.md create mode 100644 appengine/standard/django/app.yaml create mode 100644 appengine/standard/django/appengine_config.py create mode 100755 appengine/standard/django/manage.py create mode 100644 appengine/standard/django/mysite/__init__.py create mode 100644 appengine/standard/django/mysite/settings.py create mode 100644 appengine/standard/django/mysite/urls.py create mode 100644 appengine/standard/django/mysite/wsgi.py create mode 100644 appengine/standard/django/polls/__init__.py create mode 100644 appengine/standard/django/polls/admin.py create mode 100644 appengine/standard/django/polls/models.py create mode 100644 appengine/standard/django/polls/tests.py create mode 100644 appengine/standard/django/polls/views.py create mode 100644 appengine/standard/django/requirements-vendor.txt create mode 100644 appengine/standard/django/requirements.txt diff --git a/appengine/standard/django/.gitignore b/appengine/standard/django/.gitignore new file mode 100644 index 00000000000..b12c799e8c7 --- /dev/null +++ b/appengine/standard/django/.gitignore @@ -0,0 +1,49 @@ +# Global .gitignore +.DS_Store +*.pyc +.gaedata + +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + diff --git a/appengine/standard/django/CONTRIBUTING.md b/appengine/standard/django/CONTRIBUTING.md new file mode 100644 index 00000000000..6736efd943c --- /dev/null +++ b/appengine/standard/django/CONTRIBUTING.md @@ -0,0 +1,35 @@ +# How to become a contributor and submit your own code + +## Contributor License Agreements + +We'd love to accept your sample apps and patches! Before we can take them, we +have to jump a couple of legal hurdles. + +Please fill out either the individual or corporate Contributor License Agreement +(CLA). + + * If you are an individual writing original source code and you're sure you + own the intellectual property, then you'll need to sign an [individual CLA] + (https://developers.google.com/open-source/cla/individual). + * If you work for a company that wants to allow you to contribute your work, + then you'll need to sign a [corporate CLA] + (https://developers.google.com/open-source/cla/corporate). + +Follow either of the two links above to access the appropriate CLA and +instructions for how to sign and return it. Once we receive it, we'll be able to +accept your pull requests. + +## Contributing A Patch + +1. Submit an issue describing your proposed change to the repo in question. +1. The repo owner will respond to your issue promptly. +1. If your proposed change is accepted, and you haven't already done so, sign a + Contributor License Agreement (see details above). +1. Fork the desired repo, develop and test your code changes. +1. Ensure that your code adheres to the existing style in the sample to which + you are contributing. Refer to the + [Google Cloud Platform Samples Style Guide] + (https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the + recommended coding standards for this organization. +1. Ensure that your code has an appropriate set of unit tests which all pass. +1. Submit a pull request. diff --git a/appengine/standard/django/LICENSE b/appengine/standard/django/LICENSE new file mode 100644 index 00000000000..07bab4d123c --- /dev/null +++ b/appengine/standard/django/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Waldemar Kornewald, Thomas Wanschik, and all contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of All Buttons Pressed nor + the names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/appengine/standard/django/README.md b/appengine/standard/django/README.md new file mode 100644 index 00000000000..286cd6620df --- /dev/null +++ b/appengine/standard/django/README.md @@ -0,0 +1,20 @@ +# Getting started with Django on Google Cloud Platform on App Engine Standard + +This repository is an example of how to run a [Django](https://www.djangoproject.com/) +app on Google App Engine Flexible Environment. It uses the +[Writing your first Django app](https://docs.djangoproject.com/en/1.9/intro/tutorial01/) as the +example app to deploy. + + +# Tutorial +See our [Running Django in the App Engine Standard Environment](https://cloud.google.com/python/django/appengine) tutorial for instructions for setting up and deploying this sample application. + + +## Contributing changes + +* See [CONTRIBUTING.md](CONTRIBUTING.md) + + +## Licensing + +* See [LICENSE](LICENSE) diff --git a/appengine/standard/django/app.yaml b/appengine/standard/django/app.yaml new file mode 100644 index 00000000000..909a15c4cfc --- /dev/null +++ b/appengine/standard/django/app.yaml @@ -0,0 +1,43 @@ +# Copyright 2015 Google Inc. +# +# 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. + +# This file specifies your Python application's runtime configuration. +# See https://cloud.google.com/appengine/docs/managed-vms/config for details. + +# [START django_app] +runtime: python27 +api_version: 1 +threadsafe: yes + +handlers: +- url: /static + static_dir: static/ +- url: .* + script: mysite.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 +libraries: +- name: MySQLdb + version: 1.2.5 +# [END django_app] + +skip_files: +- ^(.*/)?#.*#$ +- ^(.*/)?.*~$ +- ^(.*/)?.*\.py[co]$ +- ^(.*/)?.*/RCS/.*$ +- ^(.*/)?\..*$ +- ^env/.*$ diff --git a/appengine/standard/django/appengine_config.py b/appengine/standard/django/appengine_config.py new file mode 100644 index 00000000000..6067f78e093 --- /dev/null +++ b/appengine/standard/django/appengine_config.py @@ -0,0 +1,18 @@ +# 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] diff --git a/appengine/standard/django/manage.py b/appengine/standard/django/manage.py new file mode 100755 index 00000000000..834b0091d73 --- /dev/null +++ b/appengine/standard/django/manage.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# 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. + +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/appengine/standard/django/mysite/__init__.py b/appengine/standard/django/mysite/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/appengine/standard/django/mysite/settings.py b/appengine/standard/django/mysite/settings.py new file mode 100644 index 00000000000..3aa59b29f83 --- /dev/null +++ b/appengine/standard/django/mysite/settings.py @@ -0,0 +1,136 @@ +# 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. + +""" +Django settings for mysite project. + +Generated by 'django-admin startproject' using Django 1.8.5. + +For more information on this file, see +https://docs.djangoproject.com/en/1.8/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.8/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '-c&qt=71oi^e5s8(ene*$b89^#%*0xeve$x_trs91veok9#0h0' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] + + +# Application definition + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'polls', +) + +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.security.SecurityMiddleware', +) + +ROOT_URLCONF = 'mysite.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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', + ], + }, + }, +] + +WSGI_APPLICATION = 'mysite.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.8/ref/settings/#databases + +# [START db_setup] +import os +if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'): + # Running on production App Engine, so use a Google Cloud SQL database. + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'HOST': '/cloudsql/', + 'NAME': 'polls', + 'USER': '', + 'PASSWORD': '', + } + } +else: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'HOST': '127.0.0.1', + 'PORT': '3306', + 'NAME': 'polls', + 'USER': '', + 'PASSWORD': ' Date: Mon, 12 Dec 2016 18:57:06 -0800 Subject: [PATCH 2/7] Removed gitignore file from commit --- appengine/standard/django/.gitignore | 49 ---------------------------- 1 file changed, 49 deletions(-) delete mode 100644 appengine/standard/django/.gitignore diff --git a/appengine/standard/django/.gitignore b/appengine/standard/django/.gitignore deleted file mode 100644 index b12c799e8c7..00000000000 --- a/appengine/standard/django/.gitignore +++ /dev/null @@ -1,49 +0,0 @@ -# Global .gitignore -.DS_Store -*.pyc -.gaedata - -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib64/ -parts/ -sdist/ -var/ -*.egg-info/ -.installed.cfg -*.egg - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*,cover -.hypothesis/ - From 569094f098f12c37572a359270dd42d87820c4dd Mon Sep 17 00:00:00 2001 From: Ryan Matsumoto Date: Mon, 12 Dec 2016 18:58:51 -0800 Subject: [PATCH 3/7] Added note about security of ALLOWED_HOSTS --- appengine/standard/django/mysite/settings.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/appengine/standard/django/mysite/settings.py b/appengine/standard/django/mysite/settings.py index 3aa59b29f83..8a6c920af05 100644 --- a/appengine/standard/django/mysite/settings.py +++ b/appengine/standard/django/mysite/settings.py @@ -39,9 +39,12 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True +# SECURITY WARNING: App Engine's security features ensure that it is safe to +# have ALLOWED_HOSTS = ['*'] when the app is deployed. If you deploy a Django +# app not on App Engine, make sure to set an appropriate host here. +# See https://docs.djangoproject.com/en/1.10/ref/settings/ ALLOWED_HOSTS = ['*'] - # Application definition INSTALLED_APPS = ( From 9ffcdb1d1e9a5b91becd83b3e84a551cb5866bf4 Mon Sep 17 00:00:00 2001 From: Ryan Matsumoto Date: Tue, 13 Dec 2016 13:40:37 -0800 Subject: [PATCH 4/7] Revised Django GAE Standard code based on Jons comments --- appengine/standard/django/CONTRIBUTING.md | 35 ------------------- appengine/standard/django/LICENSE | 27 -------------- appengine/standard/django/README.md | 10 ------ appengine/standard/django/app.yaml | 22 +++--------- appengine/standard/django/appengine_config.py | 1 + appengine/standard/django/mysite/settings.py | 8 +++-- appengine/standard/django/polls/admin.py | 1 - appengine/standard/django/polls/tests.py | 8 ++--- appengine/standard/django/requirements.txt | 2 -- 9 files changed, 15 insertions(+), 99 deletions(-) delete mode 100644 appengine/standard/django/CONTRIBUTING.md delete mode 100644 appengine/standard/django/LICENSE diff --git a/appengine/standard/django/CONTRIBUTING.md b/appengine/standard/django/CONTRIBUTING.md deleted file mode 100644 index 6736efd943c..00000000000 --- a/appengine/standard/django/CONTRIBUTING.md +++ /dev/null @@ -1,35 +0,0 @@ -# How to become a contributor and submit your own code - -## Contributor License Agreements - -We'd love to accept your sample apps and patches! Before we can take them, we -have to jump a couple of legal hurdles. - -Please fill out either the individual or corporate Contributor License Agreement -(CLA). - - * If you are an individual writing original source code and you're sure you - own the intellectual property, then you'll need to sign an [individual CLA] - (https://developers.google.com/open-source/cla/individual). - * If you work for a company that wants to allow you to contribute your work, - then you'll need to sign a [corporate CLA] - (https://developers.google.com/open-source/cla/corporate). - -Follow either of the two links above to access the appropriate CLA and -instructions for how to sign and return it. Once we receive it, we'll be able to -accept your pull requests. - -## Contributing A Patch - -1. Submit an issue describing your proposed change to the repo in question. -1. The repo owner will respond to your issue promptly. -1. If your proposed change is accepted, and you haven't already done so, sign a - Contributor License Agreement (see details above). -1. Fork the desired repo, develop and test your code changes. -1. Ensure that your code adheres to the existing style in the sample to which - you are contributing. Refer to the - [Google Cloud Platform Samples Style Guide] - (https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the - recommended coding standards for this organization. -1. Ensure that your code has an appropriate set of unit tests which all pass. -1. Submit a pull request. diff --git a/appengine/standard/django/LICENSE b/appengine/standard/django/LICENSE deleted file mode 100644 index 07bab4d123c..00000000000 --- a/appengine/standard/django/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) Waldemar Kornewald, Thomas Wanschik, and all contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of All Buttons Pressed nor - the names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/appengine/standard/django/README.md b/appengine/standard/django/README.md index 286cd6620df..ee13c8337b6 100644 --- a/appengine/standard/django/README.md +++ b/appengine/standard/django/README.md @@ -8,13 +8,3 @@ example app to deploy. # Tutorial See our [Running Django in the App Engine Standard Environment](https://cloud.google.com/python/django/appengine) tutorial for instructions for setting up and deploying this sample application. - - -## Contributing changes - -* See [CONTRIBUTING.md](CONTRIBUTING.md) - - -## Licensing - -* See [LICENSE](LICENSE) diff --git a/appengine/standard/django/app.yaml b/appengine/standard/django/app.yaml index 909a15c4cfc..15781218755 100644 --- a/appengine/standard/django/app.yaml +++ b/appengine/standard/django/app.yaml @@ -1,20 +1,3 @@ -# Copyright 2015 Google Inc. -# -# 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. - -# This file specifies your Python application's runtime configuration. -# See https://cloud.google.com/appengine/docs/managed-vms/config for details. - # [START django_app] runtime: python27 api_version: 1 @@ -29,11 +12,16 @@ handlers: # 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 # [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: - ^(.*/)?#.*#$ - ^(.*/)?.*~$ diff --git a/appengine/standard/django/appengine_config.py b/appengine/standard/django/appengine_config.py index 6067f78e093..f18f4328eb2 100644 --- a/appengine/standard/django/appengine_config.py +++ b/appengine/standard/django/appengine_config.py @@ -14,5 +14,6 @@ # [START vendor] from google.appengine.ext import vendor + vendor.add('lib') # [END vendor] diff --git a/appengine/standard/django/mysite/settings.py b/appengine/standard/django/mysite/settings.py index 8a6c920af05..b8e4f0ed80d 100644 --- a/appengine/standard/django/mysite/settings.py +++ b/appengine/standard/django/mysite/settings.py @@ -93,9 +93,9 @@ # https://docs.djangoproject.com/en/1.8/ref/settings/#databases # [START db_setup] -import os if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'): - # Running on production App Engine, so use a Google Cloud SQL database. + # Running on production App Engine, so connect to Google Cloud SQL using the unix socket + # at /cloudsql/ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', @@ -106,6 +106,8 @@ } } else: + # Running locally so connect to either a local MySQL instance or connect to + # Cloud SQL via the proxy. To start the proxy: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', @@ -135,5 +137,5 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ -STATIC_ROOT='static' +STATIC_ROOT = 'static' STATIC_URL = '/static/' diff --git a/appengine/standard/django/polls/admin.py b/appengine/standard/django/polls/admin.py index d7e586e3493..0c5b3a09a34 100644 --- a/appengine/standard/django/polls/admin.py +++ b/appengine/standard/django/polls/admin.py @@ -17,4 +17,3 @@ from .models import Question admin.site.register(Question) - diff --git a/appengine/standard/django/polls/tests.py b/appengine/standard/django/polls/tests.py index ccd9ecea318..c3b029bad97 100644 --- a/appengine/standard/django/polls/tests.py +++ b/appengine/standard/django/polls/tests.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from django import http -from django.test import TestCase +# Uncomment these imports and add tests here -from . import views +# from django import http +# from django.test import TestCase -# Tests go here +# from . import views diff --git a/appengine/standard/django/requirements.txt b/appengine/standard/django/requirements.txt index 65b94de1c20..ca504fefa53 100644 --- a/appengine/standard/django/requirements.txt +++ b/appengine/standard/django/requirements.txt @@ -1,5 +1,3 @@ # only install locally since GAE has its own version MySQL-python==1.2.5 Django==1.10.3 -mysqlclient==1.3.9 -wheel==0.30.0a0 From 53050d2cbcdf786b5a0da57d02a2b611e3a6f613 Mon Sep 17 00:00:00 2001 From: Ryan Matsumoto Date: Tue, 13 Dec 2016 14:00:17 -0800 Subject: [PATCH 5/7] Added comment about starting proxy from command line --- appengine/standard/django/mysite/settings.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/appengine/standard/django/mysite/settings.py b/appengine/standard/django/mysite/settings.py index b8e4f0ed80d..2f20e837cec 100644 --- a/appengine/standard/django/mysite/settings.py +++ b/appengine/standard/django/mysite/settings.py @@ -94,8 +94,8 @@ # [START db_setup] if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'): - # Running on production App Engine, so connect to Google Cloud SQL using the unix socket - # at /cloudsql/ + # Running on production App Engine, so connect to Google Cloud SQL using + # the unix socket at /cloudsql/ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', @@ -107,7 +107,10 @@ } else: # Running locally so connect to either a local MySQL instance or connect to - # Cloud SQL via the proxy. To start the proxy: + # Cloud SQL via the proxy. To start the proxy via command line: + + # $ ./cloud_sql_proxy -instances=[INSTANCE_CONNECTION_NAME]=tcp:3306 + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', From 505c42a696b337db95d50f57c9c01bba0c657512 Mon Sep 17 00:00:00 2001 From: Ryan Matsumoto Date: Tue, 13 Dec 2016 14:05:18 -0800 Subject: [PATCH 6/7] Added link to proxy doc --- appengine/standard/django/mysite/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/appengine/standard/django/mysite/settings.py b/appengine/standard/django/mysite/settings.py index 2f20e837cec..48b6c0dc4eb 100644 --- a/appengine/standard/django/mysite/settings.py +++ b/appengine/standard/django/mysite/settings.py @@ -111,6 +111,7 @@ # $ ./cloud_sql_proxy -instances=[INSTANCE_CONNECTION_NAME]=tcp:3306 + # See https://cloud.google.com/sql/docs/mysql-connect-proxy DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', From 0d7e33cc0697cc07bdf4b4e3c792274732ff6c0c Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 13 Dec 2016 14:08:35 -0800 Subject: [PATCH 7/7] Fix some minor issues --- appengine/standard/django/mysite/settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/appengine/standard/django/mysite/settings.py b/appengine/standard/django/mysite/settings.py index 48b6c0dc4eb..bd8b71a445f 100644 --- a/appengine/standard/django/mysite/settings.py +++ b/appengine/standard/django/mysite/settings.py @@ -108,9 +108,9 @@ else: # Running locally so connect to either a local MySQL instance or connect to # Cloud SQL via the proxy. To start the proxy via command line: - - # $ ./cloud_sql_proxy -instances=[INSTANCE_CONNECTION_NAME]=tcp:3306 - + # + # $ cloud_sql_proxy -instances=[INSTANCE_CONNECTION_NAME]=tcp:3306 + # # See https://cloud.google.com/sql/docs/mysql-connect-proxy DATABASES = { 'default': { @@ -119,7 +119,7 @@ 'PORT': '3306', 'NAME': 'polls', 'USER': '', - 'PASSWORD': '', } } # [END db_setup]