Snippet List
Most people simply wrap "from localsettings import *" in a try/except ImportError block. That's what I've done for years, but recently came up with this better way.
The problem this snippet solves is that if your localsettings.py itself causes an ImportError somehow, that error will be silently swallowed and your intended localsettings will be ignored. Instead, we use `imp` to first check if the module exists, then unconditionally try to import it.
- development
- staging
- production
- localsettings
Read code for info
- settings
- staging
- environment
- production
- dev
- prod
- seperation
Each installation of our Django site has slightly different settings -- namely, which database to use. Developers can provide a `local_settings.py` file which lets them override (or, just as usefully, extend) settings that are in `settings.py`.
Subversion is told to ignore `local_settings.py`, so it's never checked in.
If `local_settings.py` is missing, the site refuses to work.
We include a `local_settings_example.py` file so that new developers can get started more quickly.
- settings
- development
- deployment
- deploy
- production
- local
- local-settings
- local-deployment
4 snippets posted so far.