1. Home
  2. Computer Science MCQs
  3. Django
  4. What is the purpose of Django's values method?

Added 28 Apr 2024

What is the purpose of Django's values method?

  1. To return a list of dictionaries containing specific field values Correct answer
  2. To execute a raw SQL query
  3. To retrieve related objects after the main query is executed
  4. To perform aggregation functions on querysets

Correct answer

A. To return a list of dictionaries containing specific field values

18 views

MCQSEXAM

Explanation

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.

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Django MCQs

Practise all Django MCQs

Similar MCQs