On Apr 5, 1:00 am, Ivo Marcelo Leonardi Zaniolo <[email protected]>
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
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.