Skip to content

Common issues

Noah S. Roberts edited this page Dec 4, 2024 · 2 revisions

Static files aren't being served

Make sure your 'requirements.txt' file has Whitenoise version 6.8.x in it. Example:

# requirements.txt
whitenoise~=6.8

I'm getting environs.EnvErrors.

These can come up if you attempt to get the value of a nonexistent environment variable. If this is expected to happen, set a default value when getting the variable.

env.str('ENV_VARIABLE', default='')
#                     ^^^^^^^^^^^^

You can also quickly set the default of any unset env reads to None by running a regex find and replace in VS Code with the following:

# FIND
(env\.[a-z]+\((('[a-zA-Z_]+')|("[a-zA-Z_]+")))([, default=.*]{0})(\))

# REPLACE
$1, default=None$6

If you want a demo of how that works, this breakdown of the regex and this Stack Overflow post might help.

Clone this wiki locally