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

Added 28 Apr 2024

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

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

Correct answer

C. Inserts a new object into the database

15 views

MCQSEXAM

Explanation

save() writes the object to the database: for a new instance it inserts a new row.

If the object already has a primary key that exists in the table, the same method performs an UPDATE instead — Django decides automatically. Model.objects.create() builds and saves in one step.

Keep preparing with more Computer Science MCQs on MCQsExam.com.

Doubts & discussion

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