Blogger Template by Blogcrowds.

Introduction:
     This section will teach you to How to create complex query/filter using django Q objects.

Method:

from django.db.models import Q
    q_object = Q()
    q_object.add(Q(MyField__icontains='foo'), Q.OR) # OR'ing
    q_object.add(Q(MyField__icontains='foo'), Q.AND) # AND'ing
    q_object.add(Q(**{'MyField': 'foo'}), Q.AND) # QueryDict

0 Comments:

Post a Comment



Newer Post Older Post Home