Django development and production environments

One of the easiest solution to divide django settings for production and development environment is to create separete files for every environment. For example:


Common settings put into

But from the beggining.. create in your app folder (this is the place where you can find folder named "settings". In this folder put a file named "" and set there development environment as a default:

from import *

As the next step create a file "" with settings common for all environments.

In "" import defaults settings:

from my_app.settings.defaults import *

DEBUG = True



#and all other development specific settings, for example locale db settings

In "" you also should import defaults settings:

from my_app.settings.defaults import *

DEBUG = False

#and other production sepcific settings for example production db server settings

Your my_app folder should look like this:

  • my_app/
    • settings/

When development environment was set as a default, your production server should tell django to turn on production settings. With apache server I did it with "":

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_app.settings.production")

Add this file in git ignore list, so when you update your code, git will not upload your local "".

Second important thing could be MEDIA_ROOT and STATICFILES_DIRS path. When I've moved settings into settings folder those paths changed, so I set them like this: '../media' '../my_static'.