Possible Duplicate:
How you can manage local versus production configurations in Django?

I've handled to deploy effectively a Django project on Apache's Web Server with mod_wsgi.

I'd like some recommendations regarding how to manage multiple settings.py files. At this time I've one for development and something completely different for production (regarding DB parameters, static content localization, and things like that). My settings.py file is versioned (have no idea if this is an excellent practise) and that i deploy it with something similar to:

$ hg archive myproject.tbz2
$ cd /path/of/apache/web/project/location
$ bzip2 -db /home/myself/myproject/myproject.tbz2 | tar -xvf -

It's working OK. However I find myself adjusting multiple settings.py files.

I suppose my real question is: do you know the guidelines when implementing DJANGO PROJECTS regarding multiple settings.py file versions?

The secret that appears to become the most typical would be to maintain both a configurations.py and native_configurations.py (one for every atmosphere) file.

Atmosphere agnostic configurations get into configurations.py and at the end from the file, you'll import from local_configurations.py

try:
    from local_settings import *
except ImportError:
    pass

You are able to override any configurations.py configurations within the appropriate local_configurations.py

I personally use a configurations module that's not really a single file:

settings/
    __init__.py
    _base.py
    _servers.py
    development.py
    production.py
    testing.py

The __init__.py file is straightforward:

from _servers import get_server_type
exec("from %s import *" % get_server_type())

The _base.py file consists of all the common configurations across all server types.

The _servers.py file consists of a function get_server_type() that utilizes socket.gethostname() to determine which kind of server the present machine is: it returns development, production or testing.

Then your other files look a little like (production.py):

DEBUG=False
TEMPLATE_DEBUG=False
from _base import *

In all these files, I make the configurations that only affect this server type.

django-admin.py / manage.py both pay a --configurations=mysite.configurations option. In development you can clearly specify --configurations=dev_configurations.py. You may also set the DJANGO_Configurations_MODULE atmosphere variable inside your apache configuration.

Personally, I merely don't sign in configurations.py. Rather I sign in multiple configurations files (dev_configurations, push_configurations, etc) and symbolically link these to configurations.py as preferred. By doing this basically simply checkout my application it will not be runnable until I consider which configurations file is suitable and really put that configurations file in position.

Another suggestion I have heard however i don't particularly like is getting a configurations.py that dynamically imports a dev_configurations.py whether it is available. Although this might be easier I'd get worried it's harder to see configurations.py and understand what the configurations will really do without also searching for overriding values inside a dev_configurations.py file that might exist.

My preferred strategy is to load another ini file using ConfigParser, based off just one setting or atmosphere variable. Anyway within the django wiki you will find a variety of options referred to: http://code.djangoproject.com/wiki/SplitSettings