#29318: ValidationError has no attribute `error_list` if message is a dict, but
Field.run_validators() depends on it
     Reporter:  Michael Käufl  |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  Core (Other)   |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0

Comment (by Michael Käufl):

 Sure.  Consider a JSONField with an allowed list of keys:

 if key not in allowed_keys:
     raise ValidationError({key: 'Not allowed.'})

 We use these exceptions not only for the admin, but also for API error
 messages through django rest framework's [http://www.django-rest-
 framework.org/api-guide/exceptions/#custom-exception-handling custom
 exception handling].  This is also the reason, why we use the field's name
 in some other (therefore non-generic) validators.  Using the field's name
 as key in the error_dict, allows our front-end to display the error
 message at the affected field and not as a generic error message of the

Ticket URL: <https://code.djangoproject.com/ticket/29318#comment:2>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to