Recently, I have been optimizing some functions that were slower than expected. As with most MVPs, the initial iteration was to get something worki...
For further actions, you may consider blocking this person and/or reporting abuse
Nice post, I've recently been using Q-objects for sql, makes building dynamics queries a lot easier, for example :
Yep!
One additional trick that I haven't seen referenced many places is to use a dictionary for dynamic queries. This trick only works for ANDs, though. The dictionary should use the column name as the keyword, and the lookup as the dictionary value. Then, you can expand the dictionary into kwargs for the filter query with a double-splat (i.e.
.filter(**{})
).A silly example, but at least it gives you the idea:
github.com/chrisseto/django-include was also mentioned by a friend on Twitter for more performant many-to-x relation traversal. I haven't used it, but adding it here in case it's helpful.
Great overview. Thanks