#14184: Validators not called on MultiValueField
----------------------------------------+-----------------------------------
Reporter: anonymous | Owner: nobody
Status: new | Milestone:
Component: Forms | Version: 1.2
Keywords: MultiValueField Validators | Stage: Unreviewed
Has_patch: 0 |
----------------------------------------+-----------------------------------
Validators are not called for the compressed value of a !MultiValueField.
If, say, I have a {{{ MultiValueField }}} subclass which takes a first
name and a last name and compresses the two into a "Lastname, Firstname"
and this {{{ MultiValueField }}} subclass was instantiated using {{{
validators = [disallow_john_doe] }}}, one would expect that {{{
disallow_john_doe(compressed value) }}} would be executed. However, this
is not the case.
Looking at the source, it appears that while the {{{ clean() }}} method of
{{{ django.forms.fields.Field }}} calls {{{ run_validators() }}}, the {{{
clean() }}} method of {{{ django.forms.fields.MultiValueField }}} does
not. This is different from expected behaviour and is not documented to my
knowledge.
The workaround is to implement {{{ validate() }}} in the subclass.
--
Ticket URL: <http://code.djangoproject.com/ticket/14184>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.