#29549: ModelForms doesn't validate CHOICES
-------------------------------------+-------------------------------------
Reporter: Evgeny | Owner: nobody
Arshinov |
Type: | Status: new
Uncategorized |
Component: Database | Version: 1.11
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
This is basically a sequel of #6967.
For some reason, only form validation was considered in the original
ticket, but data validation is not limited to that, but also includes data
integrity checks running when one calls `model_instance.save()`.
As a developer, I would expect `model_instance.save()` to validate the
`choices` field against the list of possible choices, not least because
the list is defined at the model level, participates in db migrations
etc., so it should take effect on modal instances.
I haven't been able to find any documentation or existing bug reports that
clearly state that [choices
https://docs.djangoproject.com/en/2.0/ref/models/fields/#choices] argument
only affects the corresponding model form field presentation and does not
ensure data integrity.
In summary:
1. I would like to know the rationale for ignoring `choices` during data
integrity checks, in case I am missing something.
2. Please consider providing an option to turn data integrity check on.
3. If the current behavior is left intact, it should be explicitly
documented in the official documentation.
--
Ticket URL: <https://code.djangoproject.com/ticket/29549>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.efbfc4fb45eb53d8ed9869793aca4308%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.