1. Home
  2. Computer Science MCQs
  3. Django
  4. What does the delete() method do in Django models?

Added 28 Apr 2024

What does the delete() method do in Django models?

  1. Updates the existing object in the database
  2. Deletes the object from the database Correct answer
  3. Inserts a new object into the database
  4. Performs a raw SQL query

Correct answer

B. Deletes the object from the database

19 views

MCQSEXAM

Explanation

delete() removes the object from the database. It can be called on one instance or on a whole queryset, and returns the number of objects deleted.

Related objects are handled according to each ForeignKey's on_delete rule, for example CASCADE.

Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.

Doubts & discussion

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