In Django QuertSet, how to add two search queries?

33. In Django QuertSet, how to add two search queries?

  1. By using the AND keyword
  2. By using the OR keyword
  3. By using the + symbol
  4. 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.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.