On Nov 9, 12:37 pm, schlam <[EMAIL PROTECTED]> wrote:
> I am a developing in django 0.96 and therefor don't have the option to
> use form_for_model with fields, so having developed a custom form to
> add users to the database am experiencing minor problems with model
> validation.
> so my form is this :
>
> <code>
> class UserForm(forms.Form):
>         username = forms.CharField()
>         first_name = forms.CharField()
>         last_name = forms.CharField()
>         email = forms.EmailField()
>         password = forms.CharField()
> </code>
> I process the form by
> <code>
>         form = UserForm()
>         if request.method == 'POST':
>                 form = UserForm(request.POST)
>                 if form.is_valid():
>                         a=User()
>                         for i,j in form.data.items():
>                                 setattr(a,i,j)
>                         if not a.validate():
>                                 a.save()
> </code>
> if I remove the validation step, this works fine, how ever trying to
> validate raises the error
> Exception Value:        expected string or buffer
> Exception Location:     c:\Python25\lib\_strptime.py in strptime, line
> 328

Set your application in DEBUG mode and paste the entire stack trace so
people can see the sequence of events that are leading up to that
exception.

Secondly, you should be using form.clean_data instead of form.data.

> caused by the validation step... Am i just being thick?

Actually you're being thin on the info you've provided ;)


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to