On Apr 5, 1:00 am, Ivo Marcelo Leonardi Zaniolo <
imarcel...@gmail.com>
wrote:
> Hi there,
>
> I'm need to pass a QuerySet as an argument, like a function pointer that
> will be
> evaluate in other time. Somebody has one idea how I can do this?
> I dont want to create a "box" method to encapsulate it.
>
> So, can anyone help me?
QuerySets are evaluated only when accessed. So, you can just do:
def method(qs):
qs = qs.filter(somethingelse=bar)
list(qs)
qs = SomeModel.objects.filter(something=foo)
method(qs)
The queryset will be evaluated at list(qs) time.
- Anssi