[Django]-Django: environment variable for SECRET_KEY not working

4👍

.bashrc only affects bash login shells. Init scripts are not affected in any way by it.

You should copy the export SECRET_KEY=... line to the top of your init script.

6👍

You need to do:

export SECRET_KEY=secret_string

in your .bashrc. If you just do:

SECRET_KEY=secret_string

It’s only available in current process, but when you run django server/shell, the subprocess has no idea of this variable. export make the variable available in subprocesses as well.

Leave a comment