Updated Django GAE Standard Sample to CloudSQL v2 and Django 1.10#714
Updated Django GAE Standard Sample to CloudSQL v2 and Django 1.10#714
Conversation
| @@ -0,0 +1,35 @@ | |||
| # How to become a contributor and submit your own code | |||
appengine/standard/django/LICENSE
Outdated
| @@ -0,0 +1,27 @@ | |||
| Copyright (c) Waldemar Kornewald, Thomas Wanschik, and all contributors. | |||
appengine/standard/django/README.md
Outdated
| 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 |
There was a problem hiding this comment.
Link to the top-level contributing and license files or remove these sections.
appengine/standard/django/app.yaml
Outdated
| @@ -0,0 +1,43 @@ | |||
| # Copyright 2015 Google Inc. | |||
There was a problem hiding this comment.
We typically don't include this header in app.yaml.
| version: 1.2.5 | ||
| # [END django_app] | ||
|
|
||
| skip_files: |
There was a problem hiding this comment.
Can you add a comment here explaining why this is necessary and what you changed from the default.
| # https://docs.djangoproject.com/en/1.8/ref/settings/#databases | ||
|
|
||
| # [START db_setup] | ||
| import os |
There was a problem hiding this comment.
put this at the top to please the lint god.
There was a problem hiding this comment.
done - looks like os was already imported up top
| # [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. |
There was a problem hiding this comment.
How about:
# Running on production App Engine, so connect to Google Cloud SQL using the unix socket
# at /cloudsql/<connection string>
| } | ||
| } | ||
| else: | ||
| DATABASES = { |
There was a problem hiding this comment.
Add a comment here like this:
# Running locally so connect to either a local MySQL instance or connect to Cloud SQL
# via the proxy. To start the proxy:
#
# $ ...
#
| MySQL-python==1.2.5 | ||
| Django==1.10.3 | ||
| mysqlclient==1.3.9 | ||
| wheel==0.30.0a0 |
| # only install locally since GAE has its own version | ||
| MySQL-python==1.2.5 | ||
| Django==1.10.3 | ||
| mysqlclient==1.3.9 |
There was a problem hiding this comment.
Remove mysqlclient - we use this in flex because it supports Python 3.
ryanmats
left a comment
There was a problem hiding this comment.
made all changes, including a few others for linting purposes
| @@ -0,0 +1,35 @@ | |||
| # How to become a contributor and submit your own code | |||
appengine/standard/django/LICENSE
Outdated
| @@ -0,0 +1,27 @@ | |||
| Copyright (c) Waldemar Kornewald, Thomas Wanschik, and all contributors. | |||
appengine/standard/django/README.md
Outdated
| 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 |
appengine/standard/django/app.yaml
Outdated
| @@ -0,0 +1,43 @@ | |||
| # Copyright 2015 Google Inc. | |||
|
|
||
| # 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 |
| # https://docs.djangoproject.com/en/1.8/ref/settings/#databases | ||
|
|
||
| # [START db_setup] | ||
| import os |
There was a problem hiding this comment.
done - looks like os was already imported up top
| # [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. |
| } | ||
| } | ||
| else: | ||
| DATABASES = { |
| # only install locally since GAE has its own version | ||
| MySQL-python==1.2.5 | ||
| Django==1.10.3 | ||
| mysqlclient==1.3.9 |
| MySQL-python==1.2.5 | ||
| Django==1.10.3 | ||
| mysqlclient==1.3.9 | ||
| wheel==0.30.0a0 |
| } | ||
| else: | ||
| # Running locally so connect to either a local MySQL instance or connect to | ||
| # Cloud SQL via the proxy. To start the proxy: |
There was a problem hiding this comment.
You didn't add the code to start the proxy! Also, why not go ahead and link to the documentation for the proxy.
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Updated sample code and moved it from https://github.com/GoogleCloudPlatform/appengine-django-skeleton to python-docs-samples.
Tested code end to end to make sure it works locally / deployed.
Will update tutorial at https://cloud.google.com/python/django/appengine next.