Using old style DATABASE settings. Questions article's up to dateness and author's knowledge.
Importing local_settings into settings like that means it's hard for local settings to add to the various lists e.g. installed apps, middleware. It's far more flexible to import a base_settings.py into settings.py (which is the local settings file).
OA's templete thing is (if I understood it correctly) total fail. Learn about django.template.loaders.app_directories.Loader
Debug status based on domain name is not scalable, prone to error and annoying (I often need to switch debug on/off in dev/staging/production(pre-launch))
I agree with some of your comments, but to be fair this was posted in October 2009, so it's almost one year old. If I'm not mistaken, the new dictionary-style DATABASES setting is from 1.2, which only came out this year.
Not sure I agree about your comment regrading settings. It's quite easy to amend values from the main settings instead of overwriting them, you just do e.g. from settings import INSTALLED_APPS, then INSTALLED_APPS += ( ... ).
for the template dirs and the I symlink in template directorys of apps in the project. This allows me to do any additional template wackiness(like adding another directory in the path outside the project) with a symlink rather then modifying the settings file
Yikes! if socket.gethostname() == 'your.domain.com': DEBUG = False ? This is just bad advice.
I prefer to be explicit in the settings for each environment, and create a settings package, with the following modules:
- common
- development
- staging
- production
Then in each of the non-common modules import the common variables, and set your DJANGO_SETTINGS_MODULE depending on the environment. virtualenv makes this particularly easy.
Here's a writeup by Zachary Voase, who I've had the pleasure of working with more than once:
I feel much better with the signals you have raised. But I think if you have many effects on settings you will lose the bright property of Django. Everything should start from the simplest things.
I go for having a settings module which imports different things depending on what's available. For example, you can define host-specific settings based on hostname for different production servers (or production, staging, QA, etc), or just a 'local.py' for development. Regardless of what's imported, that file starts with "from base import *" which is where the main settings are.
For the curious, since everyone has their own way of doing this, my new-project init script is here: http://github.com/tvon/gig
I prefer using a separate settings_local.py, which overrides certain settings like DEBUG and the like. Then each environment can easily have its own settings_local file, excluded from code versioning.
11 comments
[ 3.2 ms ] story [ 36.5 ms ] threadOne small thing I do differently: in my dev machines, I'll set and export DJANGO_DEBUG in the environment. Then in settings.py:
This doesn't hardcode a single hostname in checked-in code, and works well across different machines and developers.Using old style DATABASE settings. Questions article's up to dateness and author's knowledge.
Importing local_settings into settings like that means it's hard for local settings to add to the various lists e.g. installed apps, middleware. It's far more flexible to import a base_settings.py into settings.py (which is the local settings file).
OA's templete thing is (if I understood it correctly) total fail. Learn about django.template.loaders.app_directories.Loader
Debug status based on domain name is not scalable, prone to error and annoying (I often need to switch debug on/off in dev/staging/production(pre-launch))
Not sure I agree about your comment regrading settings. It's quite easy to amend values from the main settings instead of overwriting them, you just do e.g. from settings import INSTALLED_APPS, then INSTALLED_APPS += ( ... ).
That said, I've found the approach to settings outline here: http://blog.zacharyvoase.com/2010/02/03/django-project-conve... to be quite intriguing and have been meaning to investigate it and possibly start using it.
No.
The default setting should be False, and set True only for dev.
I just do a standard
for the template dirs and the I symlink in template directorys of apps in the project. This allows me to do any additional template wackiness(like adding another directory in the path outside the project) with a symlink rather then modifying the settings fileI prefer to be explicit in the settings for each environment, and create a settings package, with the following modules:
- common
- development
- staging
- production
Then in each of the non-common modules import the common variables, and set your DJANGO_SETTINGS_MODULE depending on the environment. virtualenv makes this particularly easy.
Here's a writeup by Zachary Voase, who I've had the pleasure of working with more than once:
http://blog.zacharyvoase.com/2010/02/03/django-project-conve...
For the curious, since everyone has their own way of doing this, my new-project init script is here: http://github.com/tvon/gig