All I had to do is to change initial=base_data to data=base_data and the thing worked. is_valid() and is_bound now work.
Cheers, -m On 15 March 2012 12:20, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Wednesday, 14 March 2012 16:43:12 UTC-7, somecallitblues wrote: >> >> Thanks Daniel and Karen, >> >> Karen, I;'m not entirely sure what an unbound form is. :) >> > > Then you must not have read the documentation[1], which goes into great > detail about bound and unbound forms. That's pretty much a prerequisite > before asking for help, I'm afraid. > > >> >> 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) >> > > As that documentation points out, `initial` does not bind the form. > > >> 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}) >> > > Not the cause of your current problem, but this makes no sense: you can't > POST a form object. > > [1]: > https://docs.djangoproject.com/en/1.3/topics/forms/#using-a-form-in-a-view > > -- > DR. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/r8lcpGOgA5gJ. > > 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.