Which of the following is NOT a valid option for Django's ForeignKey field?
Correct answer
D. unique
15 views
D. unique
15 views
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.
Not sure why the answer is D? Ask here and get an explanation.