On Wed, Jan 6, 2010 at 3:56 PM, Joseph Kocherhans <jkocherh...@gmail.com> wrote: ... >>> On Wed, Jan 6, 2010 at 12:49 PM, Simon Willison <si...@simonwillison.net> >>> wrote: ... >>>> form = SecretQuestionForm( {"secret_question":"foo", "answer":"bar"} ) >>>> if form.is_valid(): >>>> p = form.save(commit=False) >>>> p.user = request.user >>>> p.primary_contact = somecontact >>>> p.save() ... > I had another idea that I think might work out. What if > ModelForm.validate() only validated fields on the form, like it worked > before the merge, and ModelForm.save() would automatically validate > the excluded fields, raising ValidationError if there was a problem? > Validation for each field would only happen once, it would accommodate > the commit=False idiom, and it would still ensure that the model > itself is validated in common usage.
Note that p in the example above is the unsaved model instance, not the ModelForm. So to fix the idiom, the excluded field validation would need to be done on Model.save, not ModelForm.save, right?
-- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.