Hi,
Ticket #16986 (Model.clean cannot report errors on individual fields)
was fixed in Django 1.7, but the new feature is not documented. The
Model.clean() docs still state:
> Any ValidationError exceptions raised by Model.clean() will be stored
> in a special key error dictionary key, NON_FIELD_ERRORS, that is used
> for errors that are tied to the entire model instead of to a specific
> field
The syntax to report an error on an individual field is to pass a dict
to the ValidationError constructor.
> def clean(self):
> if self.name1 == 'FORBIDDEN_VALUE':
> raise ValidationError({'name1':
[ValidationError('Model.clean() error messages.')]})
However, this is a private API. There seemed to be some debate in ticket
#20867 about whether or not to document it.
I'd be happy work on a patch to update the documentation, but I wanted
to check that it is ok to document this API.
cheers,
Alasdair
--
Alasdair Nicol
Developer, MEMSET
mail: alasd...@memset.com
web: http://www.memset.com/
Memset Ltd., registration number 4504980.
Building 87, Dunsfold Park, Stovolds Hill, Cranleigh, Surrey, GU6 8TB, UK
--
You received this message because you are subscribed to the Google Groups "Django
developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/546A1CCE.6020908%40memset.com.
For more options, visit https://groups.google.com/d/optout.