Guest User

Untitled

a guest
Feb 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. qset = (
  2.     Q(name=searched_name) &
  3.     Q(birthdate=searchet_birthdate) &
  4.     ..etc
  5. )
  6. Person.objects.filter(qset)
  7.  
  8. # BUT I DONT WANT TO ADD CERTAIN Q(..) to qset if searchet_XXX is empty string
  9.  
  10. # like for ex. searched_name = '' then just this
  11.  
  12. qset = (
  13.     Q(birthdate=searchet_birthdate) &
  14.     ..etc
  15. )
  16. Person.objects.filter(qset)
Add Comment
Please, Sign In to add comment