Home »
Python »
Django MCQs
In Django QuertSet, how to add two search queries?
33. In Django QuertSet, how to add two search queries?
- By using the AND keyword
- By using the OR keyword
- By using the + symbol
- By using the comma separator
Answer: D) By using the comma separator
Explanation:
In Django QuertSet, the filter() method is used to filter your search and returns the rows only that match the search query. If you want to add more than one query, you can place them by separating them with commas. Consider the below code statement –
dataObj = students.objects.filter(class='B.tech', lastName='Gupta').values()
Where, "students" is the model name, and "class" is the column name. The above statement will return only matched rows.