1. Home
  2. Computer Science MCQs
  3. Django
  4. Which of the following is NOT a valid option for Django's…

Added 28 Apr 2024

Which of the following is NOT a valid option for Django's ForeignKey field?

  1. to_field
  2. on_delete
  3. related_name
  4. unique Correct answer

Correct answer

D. unique

15 views

MCQSEXAM

Explanation

The correct answer is D) unique because unique is not a valid argument for Django's ForeignKey field. The to_field option specifies which field in the related model should be referenced, while on_delete defines what happens when the referenced object is deleted. The related_name option sets the name used for reverse relationships. Remember that ForeignKey creates a many-to-one relationship, while unique=True is commonly used with fields such as CharField to enforce unique values.

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