Django Production Deployment and Development Using Git
jeffknupp.com
jeffknupp.com
It sucks to keep track of dev/prod local files, it makes it hard to setup a simple script inside of a django environment, it makes multi tenant apps unnecessarily complex, app developers usually want to shove every single configuration option inside of it...
If anyone with more than a few hours of django development is doing split settings or something more complex, and even the official docs and best practices recommend doing so, why are we still stuck with it?
There are much saner ways to deal with configuration: Flask's[1] is one nice way, as is Padrino's[2].
As a Django dev, this is one of those things that actually makes me jealous of Rails, where the core devs are not afraid of breaking backwards compatibility for sanity's sake.
In my opinion it should be priority #1 for an overhaul.
[1] http://flask.pocoo.org/docs/config/ [2] http://www.padrinorb.com/guides/mounting-applications
Really, Flask's config options are better, but they aren't that different from Django. Use the default settings, tell Django which settings to use from the commandline or specify an environment variable pointing at the settings to use. Where you put those settings is completely up to you - nobody's saying they absolutely positively must be part of your repo.
When you're working with multiple environments you'll have to specify which configuration to use one way or another so I'd prefer it to use the least amount of abstraction.
Splitting settings into multiple files is the least of my problems (nowadays it is not a problem at all).
The biggest problem I have with it is that it is global, which means I cannot safely modify it at runtime.
I work on Django since about 0.9-1.0 and I remember some settings (recently cache, static media) breaking compatibility, so it's not the case. IIRC a new settings module may be introduced in 1.5
and OP's workflow can be automated with fabric.
Yes, I already use fabric for deployments.
Using a local(_)settings.py feels more esoteric than basic, because you have to find your own blog posts explaining how to do it. Having to come up with your own SECRET_KEY generator for your FOSS Django project feels hacky in a bad way.
I don't know if Django has an implementation problem, but I'd say it has a documentation problem.
I'm not super-familiar with our deployment process, but I do know that we have internal git repos that hold our production and dev environments (like local settings) and use puppet for setting up servers.
[1]: Github: https://github.com/mozilla/playdoh
[2]: Docs: http://playdoh.readthedocs.org/en/latest/index.html
A cool way to produce various settings/configurations, is using the Buildout recipe collective.recipe.genshi. This enables us to create settings based on templates, using buildout configuration parameters. Very flexible solution!
This part of the development cycle has always interested me, especially to see how other people do things.
* Check out to clean directory
* Run tests
* Zip source
* Upload
* Unzip
* Backup existing (in case of needing rollback)
* Deploy static files
* Run South db migrations
* Restart
It's very easy to get started with Fabric and once you're using it, everything can easily be automated.