Saturday, February 19, 2011

testing foo_set existence for each object in a queryset

Hi,

Long time lurker - first time poster - hopefully future answerer...

Basically what I want to do can be done with:

result = [w for w in MyModel.objects.all() if
w.foo_set.filter(endtime__gt = datetime.datetime.now()).exists()]

Is there anyway to do this using the queryset api?

Hopefully it's not too stupid a question...

--
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


Real Estate