1. Home
  2. Computer Science MCQs
  3. Django
  4. What is the advantage of Product.objects.update(stock=F('st…

Added 2 Nov 2026

What is the advantage of Product.objects.update(stock=F('stock') - 1) over reading, changing and saving in Python?

  1. It skips the database and edits a cache
  2. The database updates it atomically Correct answer
  3. It works only when DEBUG is set to True
  4. It loads every product into memory first

Correct answer

B. The database updates it atomically

13 views

MCQSEXAM

Explanation

F() expressions reference field values inside the database, so the SQL is UPDATE … SET stock = stock − 1. Concurrent requests cannot overwrite each other's changes.

Reference

Asked in: Python Developer Interviews

Preparing for an exam?

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