-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Updated Django GAE Standard Sample to CloudSQL v2 and Django 1.10 #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -0,0 +1,35 @@ | |||
# How to become a contributor and submit your own code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,27 @@ | |||
Copyright (c) Waldemar Kornewald, Thomas Wanschik, and all contributors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to the top-level contributing and license files or remove these sections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,43 @@ | |||
# Copyright 2015 Google Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically don't include this header in app.yaml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
version: 1.2.5 | ||
# [END django_app] | ||
|
||
skip_files: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment here explaining why this is necessary and what you changed from the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases | ||
|
||
# [START db_setup] | ||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this at the top to please the lint god.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
# Running on production App Engine, so connect to Google Cloud SQL using the unix socket
# at /cloudsql/<connection string>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
} | ||
else: | ||
DATABASES = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
#
# $ ...
#
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
MySQL-python==1.2.5 | ||
Django==1.10.3 | ||
mysqlclient==1.3.9 | ||
wheel==0.30.0a0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove wheel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove mysqlclient - we use this in flex because it supports Python 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made all changes, including a few others for linting purposes
@@ -0,0 +1,35 @@ | |||
# How to become a contributor and submit your own code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,27 @@ | |||
Copyright (c) Waldemar Kornewald, Thomas Wanschik, and all contributors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,43 @@ | |||
# Copyright 2015 Google Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases | ||
|
||
# [START db_setup] | ||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
} | ||
else: | ||
DATABASES = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
MySQL-python==1.2.5 | ||
Django==1.10.3 | ||
mysqlclient==1.3.9 | ||
wheel==0.30.0a0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't add the code to start the proxy! Also, why not go ahead and link to the documentation for the proxy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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.