id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 8044 random filter should be smarter about querysets Idan Gazit nobody "Apologies in advance if my terminology isn't quite right, I'm new to all of this... Right now, the random filter's implementation naively chooses from the supplied list. In the case of querysets, this might be wildly inefficient -- converting the queryset into a list causes evaluation of the entire queryset, which might be fairly large. Ideally, the desired outcome is that random will simply limit the queryset to one of its elements (or None if the queryset is empty). This patch should leave existing behavior intact for everything except querysets. Patch + documentation attached. Be gentle and tell me what to do next if something is lacking. Particularly: I think I correctly did the cross-linking to the docs about limiting querysets correctly (in the templates documentation for the random filter) -- but would appreciate a check from somebody else. Due credit for this goes to bram_ and elliott on #django; I came in there to ask about ""how best to choose a random element"" and this cropped up. The code for the filter is bram's from pastebin. The documentation and diffwork is mine. :)" closed Template system dev wontfix Design decision needed 1 0 0 0 0 0