|
31 | 31 | # Make sure to use a long unique value, like you would for a password. See: |
32 | 32 | # https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-SECRET_KEY |
33 | 33 | # https://devcenter.heroku.com/articles/config-vars |
34 | | -# SECURITY WARNING: keep the secret key used in production secret! |
| 34 | +# SECURITY WARNING: Keep the secret key used in production secret! |
35 | 35 | SECRET_KEY = os.environ.get( |
36 | 36 | "DJANGO_SECRET_KEY", |
37 | 37 | default=secrets.token_urlsafe(nbytes=64), |
38 | 38 | ) |
39 | 39 |
|
| 40 | +# Django has a debug mode which shows more detailed error messages and also means static assets |
| 41 | +# can be served without having to run the production `collectstatic` command. However, this |
| 42 | +# debug mode *must only be enabled in development* for security and performance reasons: |
| 43 | +# https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-DEBUG |
| 44 | +# Debug mode will be automatically enabled when the project is run via `heroku local` (which |
| 45 | +# loads the environment variables set in the `.env` file, where `ENVIRONMENT=development`). |
| 46 | +# SECURITY WARNING: Don't run with debug turned on in production! |
| 47 | +DEBUG = os.environ.get("ENVIRONMENT") == "development" |
| 48 | + |
40 | 49 | # The `DYNO` env var is set on Heroku CI, but it's not a real Heroku app, so we have to |
41 | 50 | # also explicitly exclude CI: |
42 | 51 | # https://devcenter.heroku.com/articles/heroku-ci#immutable-environment-variables |
43 | 52 | IS_HEROKU_APP = "DYNO" in os.environ and not "CI" in os.environ |
44 | 53 |
|
45 | | -# SECURITY WARNING: don't run with debug turned on in production! |
46 | | -if not IS_HEROKU_APP: |
47 | | - DEBUG = True |
48 | | - |
49 | | -# On Heroku, it's safe to use a wildcard for `ALLOWED_HOSTS``, since the Heroku router performs |
| 54 | +# On Heroku, it's safe to use a wildcard for `ALLOWED_HOSTS`, since the Heroku router performs |
50 | 55 | # validation of the Host header in the incoming HTTP request. On other platforms you may need to |
51 | 56 | # list the expected hostnames explicitly in production to prevent HTTP Host header attacks. See: |
52 | 57 | # https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-ALLOWED_HOSTS |
|
0 commit comments