Just sharing a function I have create to get secret from file if it is not available in environment variable. Feel free to try, all you need is to create a file call secrets.py in the same directory as your settings.py with all the secret variables you have.
to use it simple call SECRET_KEY = get_environ("SECRET_KEY")
and of cause the variable in your secrets.py should be named accordingly.
SECRET_KEY = "the-secret-to-your-django-project"
*Also, please please, don't forget to gitignore your secrets.py file!
You can also define a default value or a fallback value if everything else fails.
The priority is to first try to get the value from your environment variable if it not available then it will look for the default that you set, then, secrets.py file, then fallback.
Let me know if we could improve on it.