4 ms·
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`. http
by koliber 10y ago
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`.
https://docs.djangoproject.com/en/1.10/ref/models/querysets/#django.db.models.query.QuerySet.extra https://docs.djangoproject.com/en/1.10/ref/models/querysets/...
- StavrosK 10y agoThere'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.
- bebop 10y agoIt is the raw() function: https://docs.djangoproject.com/en/1.10/topics/db/sql/#passing-parameters-into-raw https://docs.djangoproject.com/en/1.10/topics/db/sql/#passin...