dockerizing-django icon indicating copy to clipboard operation
dockerizing-django copied to clipboard

Debug enabled in production

Open dansondergaard opened this issue 9 years ago • 5 comments

Hi,

I just noticed that, with the current setup, debug mode is enabled in production. More specifically:

https://github.com/realpython/dockerizing-django/blob/master/web/docker_django/settings.py#L26

should probably be something like DEBUG = True if os.getenv('DEBUG') == 'True' else False. I use this in my own setup and I prefer the default to be False to avoid accidentally enabling debug mode (e.g. if the setting is forgotten in .env).

I know this is only an example, but I think it's better to show people best practices :-)

dansondergaard avatar Apr 19 '16 10:04 dansondergaard

Good point. Hopefully someone using this is advanced enough to know to already do that. Want to submit a PR?

mjhea0 avatar Apr 19 '16 12:04 mjhea0

I think it's good idea to check weather DEBUG should be enabled with environment variables. If nobody have done it I can grab this task.

lisitsky avatar Nov 01 '16 13:11 lisitsky

yes. can you please grab it. thanks!

mjhea0 avatar Nov 01 '16 13:11 mjhea0

Thank you. Wow, I've delved into a code, and it's already done :) https://github.com/realpython/dockerizing-django/blob/master/web/docker_django/settings.py#L26 However how can we test this change?

lisitsky avatar Nov 01 '16 13:11 lisitsky

Hi! I've looked into YAML spec and found there're lots of ways to set "True" value for a bool variable. So it's likely somebody'll want to use another legal variant, or try to change a case. So I've added parsing for such variants. And also a test to get sure variable is handled properly. This is a "lite" version of test - it mocks env vars and thus all checks are fast. PR: #38

lisitsky avatar Nov 02 '16 19:11 lisitsky