Home »
Python »
Django MCQs
In Django QuertSet, which method is used to get each object as a Python dictionary, with the names and values as key/value pairs?
30. In Django QuertSet, which method is used to get each object as a Python dictionary, with the names and values as key/value pairs?
- values()
- dictionary()
- getvalues()
- None of the above
Answer: A) values()
Explanation:
In Django QuertSet, the values() method is used to get each object as a Python dictionary, with the names and values as key/value pairs. Consider the below code statement –
dataObj = students.objects.all().values()
Where, "students" is model name.