Essential settings to change for a Django app in production

Bevan Steele
Rock and Null
Published in
2 min readFeb 19, 2023
Photo by Carlos Alberto Gómez Iñiguez / Unsplash

So you have finished your Django app, after months of development, and you are ready to go live. Up until now, you’ve been running the app in development mode. There are a few settings that you would need to change before you can go live safely.

In this post, I will go through what I consider fundamental production settings. Nevertheless, the more complex your app, the more settings you would need to differentiate between a development and a production environment. If your app is complex, this is not a comprehensive guide for the production configuration of a Django app, rather than an essential configuration for a production environment.

Debug mode

Maybe the most important setting you would need to turn off before going into production.

The default value when you create a Django project is DEBUG = true in the settings.py accompanied by a warning to turn it off in the production. This setting is responsible for pretty-printing the error messages when something goes wrong. And even though this is extremely useful while developing an app because it's showing the stack trace along with other debug data, it's extremely dangerous information to be shown in production.

I usually set an environment variable that stores what environment is the current one. Having this information, I enable debugging only in the non-prod environments.

is_prod = os.environ.get("ENVIRONMENT", default="local") == "prod" DEBUG = not is_prod

Continue reading this post in our official blog…

--

--