Default filters: pacth to add QuerySet support for random plus a new shuffle filter
|Reported by:||h3||Owned by:||nobody|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||yes||Patch needs improvement:||yes|
I believe the way the random filter works right now is asinine or at least not very useful.
When working in templates, 90% of the lists we have to deal with are QuerySet instances, so for this filter to choke when we pass it an object list is not very helpful.
I've seen a proposed patch for this posted three years ago, but it was rejected on the ground that it required a new db hit and thus was problematic for large querysets. Fair enough.
My patch use the queryset.order_by('?') method so it (theoretically) doesn't require a new database hit.
It also introduce a new "shuffle" filter, which useful when you want to randomize a list or a queryset instead of just picking one randomly.
Change History (6)
comment:2 Changed 6 years ago by
|Patch needs improvement:||set|
|Triage Stage:||Unreviewed → Design decision needed|