Re: clean_ method not getting called

2009-05-25 Thread googletorp

Hi.
I dont see anything wrong with the form code, could be the cod in your
views that is causing the problem. Try posting that part aswell.

~Jakob

On May 25, 11:27 pm, marstein  wrote:
> I have a ModelForm like this:
>
> 
> class PlanForm(forms.ModelForm):
>     funds  = forms.ChoiceField(widget=forms.Select)
>
>     # This does get called but does not see 'funds' field!
>     def clean(self):
>         logging.debug("clean: cleaning data: %s" % self.cleaned_data)
>         return self.cleaned_data
>
>     # Does not get called!! Why?
>     def clean_funds(self):
>         data = self.cleaned_data['funds']
>         logging.debug("clean_funds: cleaning data: %s" % data)
>         return data
> 
>
> I actually started the debugger and in there I can see that the django
> \forms\forms.py(221)full_clean() method does call the ChoiceFields
> clean method first, which throws a ValidationError, and the clean_funds
> () method never gets called.
>
> Is there a way I can specify that I want to do my own cleaning? Or
> somehow point the ChoiceField to the right cleaning routine?
>
> Thanks!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



clean_ method not getting called

2009-05-25 Thread marstein

I have a ModelForm like this:


class PlanForm(forms.ModelForm):
funds  = forms.ChoiceField(widget=forms.Select)

# This does get called but does not see 'funds' field!
def clean(self):
logging.debug("clean: cleaning data: %s" % self.cleaned_data)
return self.cleaned_data

# Does not get called!! Why?
def clean_funds(self):
data = self.cleaned_data['funds']
logging.debug("clean_funds: cleaning data: %s" % data)
return data


I actually started the debugger and in there I can see that the django
\forms\forms.py(221)full_clean() method does call the ChoiceFields
clean method first, which throws a ValidationError, and the clean_funds
() method never gets called.

Is there a way I can specify that I want to do my own cleaning? Or
somehow point the ChoiceField to the right cleaning routine?

Thanks!

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---