I would like to write django filter for the following scenario. CASE : I have 4 checkboxes box1, box2, box3, box4 and a submit button on my HTML page.
I have written model post with 6 fieldd where 4 fields corresponds to box1,2,3,4. Based on the user input (4 checkboxes) it should filter the post. However does this mean i have to write 16 scenarios 4x4. or is it possible to formulate it in a better way. offcourse using if elif
post.objects.filter(Q(id=1),Q(sid=1),Q(pid=1),Q(kid=1)) # case 1
post.objects.filter(Q(id=1),Q(sid=1))
post.objects.filter(Q(id=1),Q(kid=1))
post.objects.filter(Q(id=1),Q(pid=1))
post.objects.filter(Q(kid=1),Q(sid=1))
.
.
.
post.objects.filter(Q(kid=1))
Is there a better way to do it?