How to manage Local vs Dev vs Prod in latest Django RestAPI?

github logo ・1 min read

Django Best Practices

As we have some common settings in both Local, Dev, and Prod settings, and also have settings that are different from Local, Dev, and Prod; such as database connections, installed apps, etc...I would like to start my Django app with custom file for each environment so that we can have better visibilty in settings and also will not cause git conflicts....

twitter logo DISCUSS (8)
markdown guide

I used to run a small website for my campus's library employees ran with Django. So take this with a grain of salt.

We would keep all common settings in a and then have a and You can then point to the environment specific with:

export DJANGO_SETTINGS_MODULE=<nonprod/prod>_settings.settings.

For common settings, at the bottom of our environmental settings we would from common_settings import *.

Info here:


I'd take a look at this article for how to setup multiple settings modules. However, I do use environment variables (DJANGO_SETTINGS_MODULE) to load the correct one in CI and in Docker containers.


Thanks I will test out this link and update on how it goes..


Not an avid django/python user but maybe consider keeping local, dev and prod in .env files and passing the variables into the file. That way any sensitive info is kept consistently in key value pair files and can be easily swapped. Might be inaccurately prescribed, it comes from node.js tinkering. Best of luck. 😁


We are using os.getenv method and working with .env files to set the enviroment data, works pretty well.


this article worked for me. If anyone is still looking for a solution...

Classic DEV Post from Feb 20

Sharing code examples with Carbon

A free tool to use for creating clean looking images for sharing code examples.

Suri Nuthalapati profile image
Data has a Better Idea

Creating your DEV account literally takes 30 seconds and is like casting a vote for open source, inclusion in software, and creating your profile is great for your career.

Get started now ❤️