Skip to content

Add STATIC_ROOT and MEDIA_ROOT to .env.example - #612

Merged
bpepple merged 2 commits into
Metron-Project:masterfrom
karpovantonme:env-example-static-media-root
Sep 3, 2026
Merged

Add STATIC_ROOT and MEDIA_ROOT to .env.example#612
bpepple merged 2 commits into
Metron-Project:masterfrom
karpovantonme:env-example-static-media-root

Conversation

@karpovantonme

Copy link
Copy Markdown
Contributor

What happens

.env.example opens with # Copy this file to .env and fill in all values. Doing exactly that and running manage.py fails before anything else:

$ cp .env.example .env
$ python -c "from decouple import config; config('STATIC_ROOT')"
UndefinedValueError: STATIC_ROOT not found. Declare it as envvar or define a default value.

The example sets DEBUG=True, settings.py:354 branches on if not DEBUG, and the local-storage branch reads config("STATIC_ROOT") and config("MEDIA_ROOT") with no default. Neither name is in the example.

Why declaring them rather than defaulting them

Of the 19 variables settings.py requires without a default, these two were the only ones the example did not declare. The project keeps the example complete, so this follows that rather than adding defaults to settings.py.

The values are the conventional Django ones and match how the S3 branch names things.

Alternative

If you would rather the development path work with no .env editing at all, config("STATIC_ROOT", default=BASE_DIR / "staticfiles") does that instead, and I can send it that way.

settings.py reads both through `config()` with no default, in the branch
that runs when DEBUG is on, and the example sets DEBUG=True. So copying
the file as its own first line instructs raises UndefinedValueError on
`manage.py` before anything else happens.

Of the 19 variables settings.py requires without a default, these were
the only two the example did not declare.
@bpepple bpepple self-assigned this Aug 31, 2026
@bpepple bpepple added the bug Something isn't working label Aug 31, 2026

@bpepple bpepple left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only change I made was updating the .gitignore for those directories. Thx!

@bpepple
bpepple merged commit 74ec96e into Metron-Project:master Sep 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants