Custom SQL in Django

A link published by James Bennett on June 14, 2006. Tagged with custom-managers, django, orm and sql. No comments posted.

Malcolm has been building up to this for a couple of days, and it’s really worth reading the entire progression:

  1. First he posed a puzzle: find the best way to perform a certain operation in SQL.
  2. Then he offered a couple of solutions, one that’s quick and dirty and one that’s more elegant and efficient.
  3. Finally he explains how to use a custom manager to make this easy as pie in Django.

Custom managers are another of those great relatively-untapped features of Django that really make life a whole lot easier — I use a couple of them on this site to help save keystrokes on certain common database operations, for example. There’s a little bit of official documentation on them, but they’re a relatively new concept (having recently been merged in from a long-running development branch) and it’s great to see a concrete example of what they can do.

Visit site

Comments for this link are closed. If you'd like to share your thoughts on this link with me, please contact me directly.

ponybadge