django-models-8

Last Updated :
Discuss
Comments

For a status field that uses default='draft' together with choices=[('draft', 'Draft'), ('published', 'Published')], what happens when a new instance is created without providing a value?

It always selects the first choice and does not use the default

It requires the default to be a callable and applies choices only after saving

It adds the value draft to the choices list dynamically and skips validation

It assigns draft if it exists in the choices list and raises an error only if the default is not a valid choice

Tags:
Share your thoughts in the comments