This is skeleton for Django settings as directory directory.
- Separation of sensitive & safe settings.
- Single point for version controlled project defaults: If you exclude secrets.py from your VCS you will still be able to track all safe configuration changes like adding new application or changing context processors.
- Common settings base for one-database & one-codebase multiple sites site.
- Testing near-zero-configuration.
- Ability to work with same settings but different databases on production & staging without worying about commiting staging credentials to production, etc.
- secrets.py.dist to secrets.py
- site.py.dist to anyfile.py
and configure them.
You can add more files like sitename.py or domain.py, and so on...
# runing several sites on same engine: ./manage.py runfcgi --settings=settings.whatever --socket=... ./manage.py runfcgi --settings=settings.sitename --socket=... ./manage.py runfcgi --settings=settings.domain --socket=...
I have habit of separating sensitive configuration settings like database passwords, api keys, etc into separate file.
Reason? Well, sometimes even with private repositories you work with freelance developers or you just don't trust that new guy enough to give him access to production database.
This is where this skeleton comes handy, just add <your project name>/settings/secrets.py file to your .hgignore and remember to put new sensitive data there.
You will have to come with other way of deploying this file to production machines like adding it fabric or puppet configuration.
You can also with minimal effort handle multiple sites on same engine, like:
SITE_ID = 1 LANGUAGE_CODE = 'en-us'
SITE_ID = 2 LANGUAGE_CODE = 'de-de'
Additional local.py file is there for adding anything extra to your management commands without need to call --settings=.....
Beside obvious speed up (typing) feature it can be used with multiple site setups to provide single point of "upgrade", consider this:
You have four apps "app1".."app4", and three sites "site1".."site3".
All your sites are using "app4" but app1 is used only in site1, app2 only in site2 and app3 only in site3.
Now let's assume that you have some cascading migration dependencies.
You can simply add all four apps to local.py INSTALLED_APPS += ... and migrate with simple:./manage.py migrate
You can significantly speed up testing by using:
# runing tests with in-memory database like sqlite: ./manage.py test <sometests> --settings=settings.test