1. Home
  2. Computer Science MCQs
  3. Django
  4. Which of the following is NOT true about Django's…

Added 28 Apr 2024

Which of the following is NOT true about Django's get_or_create method?

  1. It retrieves an object from the database or creates it if it doesn't exist
  2. It returns a tuple of (object, created), where created is a boolean value
  3. It raises a MultipleObjectsReturned exception if multiple objects are foun
  4. It can only be used with integer fields Correct answer

Correct answer

D. It can only be used with integer fields

19 views

MCQSEXAM

Explanation

The false statement is that get_or_create() can only be used with integer fields — it accepts lookups on any field type.

The other statements are true: it fetches the object or creates it, returns an (object, created) tuple, and raises MultipleObjectsReturned if several rows match.

Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.

Doubts & discussion

Not sure why the answer is D? 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