New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle error accessing .env file #3
Comments
Hmm, that's definitely not a typo. It's meant to catch any exception. When a file isn't found django-dotenv will issue a warning(not an exception) like "Not reading .env - it doesn't exist." The reason it's just a warning and not an exception is because the .env file is completely optional, mostly meant for development, while using real environment variables whenever you deploy to production, usually using the wsgi.py + something like gunicorn. I added the option to read the .env from the wsgi file as well for convenience while testing that out in development. |
I had a typo here ("direname"):
This caused the failure to read the Do I understand you right? You do not use |
Ah gotcha, yeah instead of swallowing any exception I should just be printing out whatever the message for the exception was, that would be good. Yeah, I don't even commit my |
Printing out whatever message comes would be helpful. I normally commit an |
Done here 3b7a398 |
Cool. |
I stumbled into an error caused by a typo in wsgi.py which prevented the settings from
.env
being imported. Since errors are not handled it took me days to find the actual problem. Therefore, I suggest you introduce some kind of error handling to notify the user.I introduced an
AttributeError
as shown below. You might wanna replace it with a more general error class.The text was updated successfully, but these errors were encountered: