What is the purpose of Django's values method?
Correct answer
A. To return a list of dictionaries containing specific field values
18 views
A. To return a list of dictionaries containing specific field values
18 views
values() returns dictionaries instead of model instances, containing only the fields you name: Book.objects.values("title", "price").
It saves memory when you need just a few columns. values_list() is similar but returns tuples.
Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.