On Aug 5, 2:23 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, Aug 5, 2010 at 12:10 AM, Ed Schofield <edschofi...@gmail.com> wrote:
> > Hi everyone,
>
> > I'm trying to use a view with multiple forms under Django 1.2.1. I'm
> > puzzled that the prefix parameter seems to screw up validation. Here's
> > a test case:
>
> > >>> from django import forms
>
> > >>> class MyForm(forms.Form):
> > >>>     field1 = forms.IntegerField(required=False)
> > >>>     field2 = forms.IntegerField()
>
> > >>> f1 = MyForm(data={'field1': 1, 'field2': 2})
> > >>> f2 = MyForm(data={'field1': 1, 'field2': 2}, prefix='p')
>
> > >>> f1.is_valid()
> > True
>
> > >>> f2.is_valid()
> > False
>
> > Can anyone explain why these are different?
>
> You need to include the prefix in the data dictionary keys for the form.
> See:http://code.djangoproject.com/ticket/13763#comment:3

Thanks, Karen.

Could I request that a note about this be added to the docs? I suggest
here:

http://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms

This would have saved me several hours (!) of head-scratching and
stepping line-by-line through Django's forms.py with pdb.

Cheers,
-- Ed

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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