Friday, April 10, 2015

Help with the following query please

This small example captures what I am actually trying to do in my application.

list = MyObject.objects.filter(field1 = entries1, field2 = entries2)

I want the query to just ignore "field2 = entries2" if entries2 is empty.  Or if entries1 is empty, I want it to ignore "field1 = entries1".

One thing I could do is just use logic to check whether entries1 or entries 2 is empty and create queries for each of the cases,

but my actual application has much more than two fields to check. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bedeb84f-4c1f-41ba-8444-d5ec833ae24a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment