akv akv - 2 years ago 140
Python Question

How to manage local vs production settings in Django?

A Django newbie question:

What is the recommended way of handling settings for local development and the production server? Some of them (like Constants, etc) can be changed/accessed in both, but some of them (like paths to static files) need to remain different, and hence should not be overwritten everytime the new code is deployed...

Currently, I am adding all constants to settings.py. But every time I change some constant locally, I have to copy it to the production server and edit the file for production specific changes... :(

Edit: looks like there is no standard answer to this question, I've accepted the most popular method.

Answer Source

In settings.py:

    from local_settings import *
except ImportError as e:

You can override what needed in local_settings.py; it should stay out of your version control then. But since you mention copying I'm guessing you use none ;)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download