Re:Harmful Defaults in Django
by jmconfuzeus on Friday January 07, 2022 @12:12PM
(#29841694)
It's highly unlikely that will you execute unnecessary queries from view code because usually you'll have a context like {"pizzas": page_obj.object_list}. You'll almost never execute something like:
But you'll certainly do the following in templates:
I also don't understand why you want to avoid 3rd party packages, especially if it helps you write better code.
[ Parent
| on HN ]
My argument was that the third-party package is what's key here. Merely converting your querysets to a list in code before handing it off to the template won't fully protect you against extra queries.
I'm not necessarily trying to avoid third-party packages, in fact I've installed the package you suggested in one of my projects and will be trying it out.