I believe you can just do
if query:

This will execute the query, so if it is a particularly intensive one
you may want to come up with a simpler version of it for testing
existance.

On Jan 28, 12:10 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Is there a better way to check if there are any hits on a query than
> using query.count()>0 ?
>
> I find myself doing something like this a lot:
> modelList = MyModel.objects.filter(someMember=m)
> if modelList.count() > 0:
>   return modelList[0]
>
> I really don't care how many there are, so the count might be a waste.
> But if the count just checks the max index, and is an O(1) operation,
> I don't really care too much.
>
> Ivan
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to