Hi,

I’m taking https://code.djangoproject.com/ticket/28788 
<https://code.djangoproject.com/ticket/28788> to this mailing as per Tim’s 
request.

I’m convinced we should add a Model.clean_<fieldname> method, the model 
equivalent to Form.clean_<fieldname>.

Form validation has forms.Field.validators, Form.clean, and 
Form.clean_<fieldname>.
Model validation has models.Field.validators, Model.clean, but no 
Model.clean_<fieldname>.

Using Field.validators works, but is cumbersome and inelegant as you’ll have to 
put model validation logic outside the model definition.

Model.clean_<fieldname> also helps you structure your validation logic, 
particularly if subclasses are involved.

Backwards compatibility is an issue with my suggestion that is yet to be 
solved. We don’t want surprising calls to clean_XXX methods that were defined 
before this feature was introduced.

I’m curious to hear what everyone else thinks!

Jonas

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/D7A48F7D-0A60-4ADF-B210-F73FA1F0B717%40lophus.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to