Thanks Daniel and Karen,

Karen, I;'m not entirely sure what an unbound form is. :)

Anyway, this is my test code:

def test_appointment_form(self):

        c = Client()

        base_data = {
            'name':'Foo name',
            'slug':'foo-session',
            'short_descr':'foo tagline',
            'long_descr':'long foo description',
            'staff':self.staff,
            'business':self.business,
            'start_date':'2012-07-24',
            'end_date':'2012-07-24',
        }
        self.form =
AppointmentForm(business=self.business,staff=self.staff,initial=base_data)

        self.failUnless(self.form.is_valid()) #<---- This fails

        print self.form.errors #<----This doesn't print anything

        response = c.post('/console/appointments/add', {'form':self.form})
        self.assertEqual(response.status_code, 302)

This is form code:

class AppointmentForm(forms.Form):
    name = forms.CharField(label='Appointment Name (80 Characters Max)',
max_length=NAME)
    short_descr = forms.CharField(label='Tagline', max_length=SUMMARY)
    #some more stuff here and the __init__ function below it

I'm not going the right way about this, am I? :) How can I see why the
validation fails in my unit test?

I get the same thing if I work in shell.

Cheers,

-m


On 14 March 2012 23:20, Karen Tracey <kmtra...@gmail.com> wrote:

> The most common reason I have seen for is_valid() to return False but
> errors to be empty is for the form to be unbound. Unbound forms are
> never valid, but they also don't have any errors. Which goes to
> Daniel's question: how exactly have you "preloaded" the form with
> data?
>
> Karen
> --
> http://tracey.org/kmt/
>
> --
> 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.
>
>

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