- Notifications
You must be signed in to change notification settings - Fork 6.6k
Add new django tutorial #4869
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
Merged
Merged
Add new django tutorial #4869
Changes from all commits
Commits
Show all changes
119 commits Select commit Hold shift + click to select a range
ff73fca Cloud Run with Django tutorial
glasnt b5ccc3c Cloud Run with Django tutorial
glasnt 6ea8b1b Merge branch 'tutorial/django-run' of github.com:glasnt/python-docs-s…
glasnt 1ba9285 black, .env file update
glasnt e6c9362 Document Dockerfile, add PYTHONUNBUFFERED
glasnt 7cd94bb Document cloudmigrate.yaml
glasnt 01fbedf Formatiting
glasnt 711a50f Bump django, remove mysql
glasnt b01118d Merge branch 'master' into tutorial/django-run
glasnt 97088bd Update secretmanager
glasnt a3960e8 Update pinned dependencies
glasnt c0a4753 ensure path is set correctly with api update
glasnt e75ee59 format
glasnt 55db6c4 Generalise cloudmigrate file
glasnt b0d3e61 update service default
glasnt b39521b add tests
glasnt a0c90a4 Update CODEOWNERS
glasnt 79a0c11 Merge branch 'master' into django-run
glasnt 60f54fd Merge branch 'master' into django-run
glasnt 083145a Licence headers
glasnt 0508de3 Remove envvar declaration
glasnt 4ae043e cleanup readme
glasnt 0fea1a4 Fix import names, region tags
glasnt 59a690a black
glasnt 3297a13 Merge branch 'django-run' of github.com:glasnt/python-docs-samples in…
glasnt 43311df Cloud Run with Django tutorial
glasnt 192547a black, .env file update
glasnt 4d8ec6f Document Dockerfile, add PYTHONUNBUFFERED
glasnt 9fb3094 Document cloudmigrate.yaml
glasnt 885d44f Formatiting
glasnt b56ecdf Bump django, remove mysql
glasnt 3897bad Update secretmanager
glasnt a453f02 Update pinned dependencies
glasnt 7981375 ensure path is set correctly with api update
glasnt 756daf9 format
glasnt 86573fe Generalise cloudmigrate file
glasnt 9a94cb2 update service default
glasnt 6426d01 add tests
glasnt 8fa8c19 Update CODEOWNERS
glasnt be5911a Licence headers
glasnt cb5992e Remove envvar declaration
glasnt 8c643d4 cleanup readme
glasnt 98837e1 Fix import names, region tags
glasnt 5e1cb0a black
glasnt 0308d64 Merge branch 'django-run' of github.com:glasnt/python-docs-samples in…
glasnt 911ca50 black
glasnt 877c658 Format YAML
glasnt 700a2cd Merge branch 'master' into django-run
glasnt 466a801 bump dependencies
glasnt c188733 Update var names, remove sql instance creation
glasnt 4d33c68 PR Feedback
glasnt 344f35e Merge branch 'master' into django-run
glasnt 3ed2a6e Debug failing command
glasnt 8fa7cc3 Merge branch 'django-run' of github.com:glasnt/python-docs-samples in…
glasnt 8f854e9 Remove IAM calls - possible permissions issues
glasnt 1809ab5 debug
glasnt cefb39a force local settings if in nox/test
glasnt 2b61310 add IDs to cloud build
glasnt cd0b8d1 Update region tags
glasnt 9492d67 Get instance name from envvar
glasnt 2601b22 Make secrets dynamic, optionally overload names by envvar
glasnt 2ca3427 Remove create/destroy of static setting
glasnt f1b79c2 Consolidate envvars
glasnt e9cbe76 Merge branch 'master' into django-run
glasnt e8556fc Merge branch 'django-run' of github.com:glasnt/python-docs-samples in…
glasnt 738a9b5 fix region tags
glasnt e62e4d3 lint, import error
glasnt e51cd2b Testing instance name is fqdn, need just name for gcloud sql calls
glasnt 7837611 Ensure project specified on gcloud calls
glasnt 460b5ff set project when using gsutil
glasnt 6fce68c order of flags in gsutil matters
glasnt 2b09698 ensure all subprocesses include project
glasnt cb5ea1e Add and remove more project tags
glasnt 9877d70 Update comments
glasnt 04c0900 match on exact project name, not substring
glasnt 895f8fb lint
glasnt 05aa42c Can't hide the settings name in the setting itself 🧐
glasnt 1db86b5 big oof
glasnt d8a557f migrations require __init__.py to be detected
glasnt 87ebb84 Bump overnight patch
glasnt adc6fda Debug 503
glasnt 4a956fb Service requires custom settings envvar
glasnt 9a48ab4 attempt fixing local tests
glasnt 6d544f2 lint
glasnt 7986d66 Merge branch 'master' into django-run
glasnt 7ffff2d revert accidental appengine change
glasnt d529d19 envvars
glasnt e6caaf7 Merge branch 'django-run' of github.com:glasnt/python-docs-samples in…
glasnt 1edf555 ohno
glasnt d95a698 wrong varname
glasnt 9bf42d4 Merge branch 'master' into django-run
glasnt 28b12a0 Merge branch 'master' into django-run
glasnt c55cdea Merge branch 'master' into django-run
glasnt c7034b1 Update run/django/noxfile_config.py
glasnt 14371a4 Add licence header
glasnt e31e692 Formatting
glasnt e4dd31f black
glasnt 8712b3f Add typehinting, remove debugging
glasnt eeca3c2 Merge branch 'master' into django-run
glasnt 652d5ee ⚠️ noxfile change - add typehints
glasnt 08d2961 ⚠️ noxfile change - fix method signature
glasnt e441b59 ⚠️ noxfile change - fix nox session type
glasnt 763ad5b ⚠️ noxfile change - import order
glasnt 82df36f hadolint Dockerfile
glasnt 5395697 revert hadolint
glasnt 620b626 Merge branch 'master' into django-run
glasnt e1d465c Merge branch 'master' into django-run
glasnt 4f1063a Merge branch 'master' into django-run
glasnt 0d78748 Merge branch 'master' into django-run
glasnt 80c66ab Merge branch 'master' into django-run
glasnt 2fd21a4 Merge branch 'master' into django-run
glasnt a18d3fe Add linking
glasnt 5e78fdb Remove gcloudignore
glasnt 2109542 Merge branch 'django-run' of github.com:glasnt/python-docs-samples in…
glasnt 6f9c0ff Merge branch 'master' into django-run
glasnt 7dd2052 Merge branch 'master' into django-run
glasnt 60699a9 Testing: i have a theory this is why tests started failing
glasnt 2574096 Merge branch 'django-run' of github.com:glasnt/python-docs-samples in…
glasnt 83fc6b2 Merge branch 'master' into django-run
glasnt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Copyright 2020 Google LLC | ||
| # | ||
| # 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. | ||
| | ||
| # Use an official lightweight Python image. | ||
glasnt marked this conversation as resolved. Show resolved Hide resolved | ||
| # https://hub.docker.com/_/python | ||
| FROM python:3.8-slim | ||
| | ||
| ENV APP_HOME /app | ||
| WORKDIR $APP_HOME | ||
| | ||
| # Removes output stream buffering, allowing for more efficient logging | ||
| ENV PYTHONUNBUFFERED 1 | ||
| | ||
| # Install dependencies | ||
| COPY requirements.txt . | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
| | ||
| # Copy local code to the container image. | ||
| COPY . . | ||
| | ||
| # Run the web service on container startup. Here we use the gunicorn | ||
| # webserver, with one worker process and 8 threads. | ||
| # For environments with multiple CPU cores, increase the number of workers | ||
| # to be equal to the cores available. | ||
| CMD exec gunicorn --bind 0.0.0.0:$PORT --workers 1 --threads 8 --timeout 0 mysite.wsgi:application | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Getting started with Django on Cloud Run | ||
| | ||
| [![Open in Cloud Shell][shell_img]][shell_link] | ||
averikitsch marked this conversation as resolved. Show resolved Hide resolved | ||
| | ||
| [shell_img]: http://gstatic.com/cloudssh/images/open-btn.png | ||
| [shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=run/django/README.md | ||
| | ||
| This repository is an example of how to run a [Django](https://www.djangoproject.com/) | ||
| app on Google Cloud Run (fully managed). | ||
| | ||
| The Django application used in this tutorial is the [Writing your first Django app](https://docs.djangoproject.com/en/3.0/#first-steps), after completing [Part 1](https://docs.djangoproject.com/en/3.0/intro/tutorial01/) and [Part 2](https://docs.djangoproject.com/en/3.0/intro/tutorial02/). | ||
| | ||
| | ||
| # Tutorial | ||
| See our [Running Django on Cloud Run (fully managed)](https://cloud.google.com/python/django/run) tutorial for instructions for setting up and deploying this sample application. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Copyright 2020 Google LLC | ||
| # | ||
| # 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. | ||
| | ||
| steps: | ||
| - id: "build image" | ||
| name: "gcr.io/cloud-builders/docker" | ||
| args: ["build", "-t", "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}", "."] | ||
| | ||
| - id: "push image" | ||
| name: "gcr.io/cloud-builders/docker" | ||
| args: ["push", "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}"] | ||
| | ||
| - id: "apply migrations" | ||
| name: "gcr.io/google-appengine/exec-wrapper" | ||
| args: | ||
| [ | ||
| "-i", | ||
| "gcr.io/$PROJECT_ID/${_SERVICE_NAME}", | ||
| "-s", | ||
| "${PROJECT_ID}:${_REGION}:${_INSTANCE_NAME}", | ||
| "-e", | ||
| "SETTINGS_NAME=${_SECRET_SETTINGS_NAME}", | ||
| "--", | ||
| "python", | ||
| "manage.py", | ||
| "migrate", | ||
| ] | ||
| | ||
| - id: "collect static" | ||
| name: "gcr.io/google-appengine/exec-wrapper" | ||
| args: | ||
| [ | ||
| "-i", | ||
| "gcr.io/$PROJECT_ID/${_SERVICE_NAME}", | ||
| "-s", | ||
| "${PROJECT_ID}:${_REGION}:${_INSTANCE_NAME}", | ||
| "-e", | ||
| "SETTINGS_NAME=${_SECRET_SETTINGS_NAME}", | ||
| "--", | ||
| "python", | ||
| "manage.py", | ||
| "collectstatic", | ||
| "--no-input", | ||
| ] | ||
| | ||
| substitutions: | ||
| _INSTANCE_NAME: django-instance | ||
| _REGION: us-central1 | ||
| _SERVICE_NAME: polls-service | ||
| _SECRET_SETTINGS_NAME: django-settings | ||
| | ||
| images: | ||
| - "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.