| published by | Adam Johnson |
|---|---|
| in blog | Adam Johnson |
| original entry | Django: avoid “useless use of .all()” |
Here’s a little ORM pet peeve of mine that may deepen your understanding of how QuerySets work.
Take this code:
Digger.objects.all().filter(height_cm__gt=200)
The .all() is unnecessary.
It’s equivalent to write:
Digger.objects.filter(height_cm__gt=200)
Why?
The manager, Digger.objects, already refers to …