On Fri, Jan 8, 2010 at 4:03 AM, James Bennett <[email protected]> wrote:

> On Thu, Jan 7, 2010 at 10:40 AM, Honza Král <[email protected]> wrote:
> > ModelForm has a save() method that saves the model. It is reasonable
> > to assume that if the form is valid, the save() method call should
> > succeed, that's why the entire model is validated.
>
> Actually, I can see a strong argument against this: if I've defined a
> form class that I think constructs valid instances, and it doesn't,
> that's a bug in my form and Django should be making this as clear as
> possible.
>
> Of course, the flip side is that the bug in my form may be something
> subtle which breaks a constraint specified at the Python level but not
> at the DB level, and so the additional automatic validation could be
> the only way to catch it.
>

For another alternative still, a constraint may exist at the database level
that Python doesn't know about (or may not be able to enforce efficiently).

I regret and apologize that I'm arriving to this thread rather late.  Is
there a document somewhere that discusses, or could someone describe, how
model validation fits between the existing form validation in Django and
constraints that are specified on the database side?

I too would opt for an implementation that makes model validation optional,
i.e., a call that developers must explicitly make, if they choose, before
saving a model.  I've always been and I continue to be wary of trying to
implement data constraints at the application level; that's something good
relational databases have been doing and improving upon for a long time and
I have little faith in my own capacity to reproduce or replace such
functionality.

Cheers,
Tobias
-- 
Tobias McNulty
Caktus Consulting Group, LLC
P.O. Box 1454
Carrboro, NC 27510
(919) 951-0052
http://www.caktusgroup.com
--
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