Django Q objects


/ Published in: Django
Save to your folder(s)



Copy this code and paste it in your HTML
  1. from django.db.models import Q
  2.  
  3. Publisher.objects.filter(Q(state_province="CA") | Q(state_province="AZ"))
  4.  
  5. #or also more programmatically:
  6.  
  7. args = ( Q( title__icontains = 'Foo' ) | Q( title__icontains = 'Bar' ) )
  8. entries = Entry.objects.filter( *args)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.