Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the Q object in Django to filter two different column values together. Here's an example:

from django.db.models import Q

MyModel.objects.filter(Q(column1=value1) & Q(column2=value2))

In this example, MyModel is the model that you're querying, and column1 and column2 are the names of the columns that you're filtering on. value1 and value2 are the values that you're filtering for.

The Q object allows you to combine multiple filters with & (and) and | (or) operators. In this case, we're using & to filter on both column1 and column2.