Alex Rivera | Logout

django manage.py settings default

Asked 2011-11-29T22:31:10.017
15

I have a settings.py file and a dev_settings.py file that I use to override some values for dev purposes. Everytime I run the ./manage.py command, I have to specify --settings=whatever.local_settings. This becomes very tedious to do every time and I am trying to find a way to force manage.py to load my dev_settings.py file every by default so that I don't have to type that long argument every time I want to run a command.

I have tried setting DJANGO_SETTINGS_MODULE, however, it appears that manage.py overrides this option.

Is it possible to make this happen or am I doomed to always specify that argument?

Edit
Report

1 Answer

1

If a settings file is common to all installation, you can just import it e.g.

from settings_local import *

but usually settings_local are changed and tweaked per installation and as my installation script directly copy files to target sites (without worrying what is local what is not), which mean settings_local may get overwritten, to avoid that I just keep settings_local in parent folder of the installation target and manually import it in settings.py e.g.

local_settings_file = os.path.join(prevFolder, "settings_local.py")
if os.path.exists(local_settings_file):
    execfile(local_settings_file)
answered 2011-11-29T23:16:19.647

Your Answer