March 2009
4 posts
I need to see what’s inside that box. If I learned anything from 24,...
– 30 Rock, “Apollo, Apollo”
Worst Line of Code and Why
I needed to grab the latest Link object for a certain Forum from Django’s ORM.
Normally, I’d do this with:
link = forum.link_set.order_by('-id')[0]
But for some reason, adding the slice (which adds a limit to the SQL query), was considerably slowing down the call. Whereas, just getting the iterator was fine.
link_qs = forum.link_set.order_by('-id')
Which is disturbing. I...