Skip to content

Commit db182f7

Browse files
authored
feat: Prevent overriding the value from config (GoogleCloudPlatform#7218)
## Description Fixes #<ISSUE-NUMBER>Previously the DEBUG env var will always be overridden into True, while we already have a way to read it from env var. By setting the default value as True and not overridding the value later we can retainthe DEBUG value provided from the users. Note: It's a good idea to open an issue first for discussion. ## Checklist - [x] I have followed [Sample Guidelines from AUTHORING_GUIDE.MD](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md) - [x] **Tests** pass: `nox -s py-3.6` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#test-environment-setup)) - [x] **Lint** pass: `nox -s lint` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#test-environment-setup)) - [x] Please **merge** this PR for me once it is approved.
1 parent f4d2a20 commit db182f7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

run/django/mysite/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2323

2424
# [START cloudrun_django_secret_config]
25-
env = environ.Env(DEBUG=(bool, False))
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
# Change this to "False" when you are ready for production
27+
env = environ.Env(DEBUG=(bool, True))
2628
env_file = os.path.join(BASE_DIR, ".env")
2729

2830
# Attempt to load the Project ID into the environment, safely failing on error.
@@ -61,9 +63,7 @@
6163
# [END cloudrun_django_secret_config]
6264
SECRET_KEY = env("SECRET_KEY")
6365

64-
# SECURITY WARNING: don't run with debug turned on in production!
65-
# Change this to "False" when you are ready for production
66-
DEBUG = True
66+
DEBUG = env("DEBUG")
6767

6868
# SECURITY WARNING: It's recommended that you change this setting when
6969
# running in production. The URL will be known once you first deploy

0 commit comments

Comments
 (0)