You may be interested in the `.extra(...)` call on a QuerySet in Django. It allows you to specify hand-written SQL for various clauses, including `WHERE`.
There's also a method (I forget the name, as I've never used it) where you write the full SQL and just tell Django which models' rows it's supposed to be returning, and it will build model instances from the returned SQL. Pretty nifty.