On Thu, Jan 21, 2010 at 1:28 PM, Gerry <[email protected]> wrote:
> without using ModelForms? I really like the new Model validation but I
> don't
> like (nor think its very DRY) to override the save method for all of
> my models
> to just call full_clean(). It would be nice if there was someway I
> could enable
> validation by default.

The problem with this is that it can't really be generalized. One of
the reasons why ModelForm has the implementation it does is that often
you have a form which doesn't contain all the fields from the model,
or a view which uses the form for initial validation, then does
further work before finally saving a complete, valid object.

Similarly, being at the stage of calling save() doesn't necessarily
mean that the object is complete and valid; one common example is
default values, which won't yet be filled in when your custom save()
method tries to validate the object, resulting in a validation failure
even though the object *would* be valid by the time it hit the
database.

Developing an "automatic" validation option which is both simple
enough to actually be useful and robust enough to handle all the edge
cases is -- if it's even possible -- far more than can be accomplished
on the 1.2 timeframe. Hence, for now, Django doesn't have any such
thing, and won't have it in 1.2. If you think you can make it work for
1.3, your best bet is to work up a proposal, including at least some
sample code, along with an explanation of how you'll keep it both
simple and robust.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en.

Reply via email to