Django Best Practices — Updated for 1.4
lincolnloop.com
lincolnloop.com
I'm a novice Django programmer, and was surprised that I gained very little knowledge by looking at this document. I wish I could report happier news.
I should be keeping a list of Django annoyances and questions, because then I could propose a list of topics for Django best practices that I'd like to see answered. But I can't remember them off the top of my head.
https://github.com/lincolnloop/django-layout
This structure leaves manage.py in the root path. Which mean other dirs will pollute this area, like run/, deploy/, log/, config/, lib/, bin/, cronjobs/, etc. You dirs woud stack to a long list.
I would suggest something like this:
root/
src/
manage.py
lib/
run/
docs/
config/Edited some spelling...
If you want to invoke some Django-based logic at regular intervals without having to install Celery (and monitoring and a decent queue) you'll opt for a management command. The link you posted should help you out here. Invoking the script yourself or telling cron to invoke it for you shouldn't be hard if you know about cron.
With regards to Celery: I think the tutorial and docs are pretty clear on how to use it and how to set it up.
I've been deploying two projects to AWS very recently and we've been using django-pipeline and django-storages (with s3 boto storage) for asset management. ./manage.py collectstatic and all your static files are up on S3. With a bit of finagling around[1] you can even have user uploads hit there seamlessly as well.
[1]: http://stackoverflow.com/questions/10390244/how-to-set-up-a-...
EDIT: Pipeline isn't necessary for storing static files on S3, but if you want to compile SASS/LESS/cs files or any transforms really it works really well.
* https://github.com/lincolnloop/django-best-practices/issues/... * https://github.com/lincolnloop/django-best-practices/issues/...
If you think of any more, feel free to file your own.
Myself, I'm swinging between the two still, haven't found a convincing argument either way.
# allow overriding of settings with $HOME/.sodahead
rc = os.path.join(os.environ["HOME"], ".sodahead")
if os.path.isfile(rc):
with open(rc, "r") as fi:
dotsodahead = imp.load_source("dotsodahead", rc, fi)
settings = dict([(k, v) for k, v in vars(dotsodahead).items()
if not k.startswith("__")])
globals().update(settings)Even if you use environment variables, you need them stored somewhere (a secrets.py file, a .env file, a upstart script) so they get onto the machine at startup. At the moment we're kicking around GPG encrypting the data and only decrypting it on the machines that need it.
Feel free to cross-pollinate! </shameless-plug>