10 Tools That Make Django Better

The last few weeks I’ve been experimenting with different Django setups, which virtualenv makes trivial. (If you’re not using virtualenv and virtualenvwrapper for Python development, the secret is to bang the rocks together guys!) My goal has been to create a reusable project framework for quick social experiments that provides the following features:

To that end, I’ve managed to refine my base project to the following:

  1. Django SocialAuth, providing oauth account creation and login. Extremely quick to implement multi-site auth, and even contact imports.
  2. Django Debug Toolbar. The swiss pocketknife of debug tools, this outputs an overlay through your HTML templates and offers detailed information from SQL queries, settings, request timings, cookies, signals, and even full profiling.
  3. Sentry. This fantastic app integrates with Django to log exceptions to the database, and offers real-time reporting and tracking of them. Makes tracking errors on your production environment significantly easier.
  4. South is the de-facto schema migration tool for Django. Others exist, but the momentum behind South has reached the point where it’s difficult to find one that has undergone as much scrutiny.
  5. Celery, and RabbitMQ. It’s difficult to separate these two, although possible if you need to run Celery with some kind of ghetto queue behind it. Simply put, Celery allows you to designate Python functions run to asynchronously or under a schedule like a cron task. If you’ve got a heavy bit of processing that doesn’t need to be done during a request, throw it at Celery and it will get done as soon as possible without slowing your site down for the user. RabbitMQ is the message queue that manages running these tasks.
  6. Green Unicorn. Despite the whimsical name, this handy lightweight HTTP server makes running Django as a WSGI app pure simplicity. Just add ‘gunicorn’ to INSTALLED_APPS, and ./ run_gunicorn. Then proxy to it with your favourite web server for production deployment. Green Unicorn provides both synchronous and asynchronous worker threads depending on your needs.
  7. Fabric is the webapp deployment tool of the moment. It provides an API for executing Python commands over SSH, so that you can test, deploy and run your django project to any number of hosts with a single command.
  8. Django Messages is a simple messaging application with an inbox, sent messages, and trash. Very easy to setup and configure.
  9. Django Friends is a fully-featured contact system for social sites. It covers relationship types, invitations, contact tracking (for when invitees aren’t yet members of the site), and can even do indirect relationships (friend of a friend).
  10. Brabeion. This final component is a reusable Django application for creating a rewards system with badges. Simply define the badge names and some arbitrary scoring system, and then call a function with the user and score to assign the badge if the user meets the requirements. Works very well in combination with Celery tasks for computing complex scoring.

More on the projects I’ve been using these for in the very near future!

Short link: