Hello,

after hours of examinating and debugging the Django source code I
decided to post my problem here.

I'm using Django 1.3.1 and its docs say:


The is_valid() method and errors
Changed in Django 1.2: Please, see the release notes

The first time you call is_valid() or access the errors attribute of a
ModelForm has always triggered form validation, but as of Django 1.2,
it will also trigger model validation. This has the side-effect of
cleaning the model you pass to the ModelForm constructor. For
instance, calling is_valid() on your form will convert any date fields
on your model to actual date objects.


I'm using a FormView with a ModelForm. No matter if I add an instance
to the forms kwargs, the model.full_clean method is *not* called by
form.is_valid(). This is working fine later by

def form_valid(.....
    ....
    self.obj= form.save(commit=False)
    self.obj.full_clean()

I thought my python skills would be OK after one and a half year of
django programming, but I neither get why the _errors attribute of the
BaseForm (forms.Form:109) is always ErrorDict, even directly after
assigning it to None (forms.Form:84) according to the pydev-debugger,
and therefore form.clean() is never called - nor where the
model.full_clean() method is called at all. The implementation of
ModelForm/BaseModelForm is not that confusing.
I would be lucky if someone could explain to me why model validation
is not triggered with my ModelForm and where to find the piece of code
that does it.

If you need more information, just ask, please.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to