Operators that return new QuerySets✅

 1) AND(&) - Combine two QuerySets using SQL AND operator.

Example - 

student_data = student.objects.fitler(id=6) &  student.objects.fitler(roll=107)

student_data = student.objects.fitler(id=6, roll=107)

student_data = student.objects.fitler(Q(id=6) &  Q(roll=107))

SQL Query : select * from student where id=6 AND roll=107

2) OR(|) - Combine two QuerySets using SQL OR operator.

Example - 

student_data = student.objects.fitler(id=6) |  student.objects.fitler(roll=107)

student_data = student.objects.fitler(Q(id=6) |  Q(roll=107))

SQL Query : select * from student where id=6 OR roll=107


Post a Comment

0 Comments