Re: Django Model - create a filter and use it as argument
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
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home