django manage.py settings default

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?

Answers


manage.py sets path to settings for you, that's why it's ignoring DJANGO_SETTINGS_MODULE (it's basically just script that wraps around django-admin.py).

There are 2 easy ways to fix your problem:

  1. set DJANGO_SETTINGS_MODULE and use django-admin.py to run all commands instead of manage.py. This is even better if you use vitualenv.

  2. copy manage.py and name it local.py (that's the name in my case) and rename all settings mentions to dev_settings.

For example:

#!/usr/bin/env python
from django.core.management import execute_manager
import imp

try:
    import settings_local
except ImportError:
    import sys
    sys.stderr.write("Error: Can't find the file 'settings_local.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(settings_local)

You can run all commands by ./local.py now.


Need Your Help

Alternative to header(location: ) php

php header

I have a while loop that constructs a url for an SMS api.

KeepAlive HTTP Requests on Appengine

http google-app-engine node.js keep-alive

Is it possible to have a HTTP keep-alive Request on Google Appengine much like node.js ?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.