Well, Form.is_valid calculates the form and returns boolean, thats for sure.
Specifically, "<bound method ContactForm.is_valid of <beppe.forms.ContactForm 
object"
means that "is_valid" is a ``method`` bounded to instance of your form class.

Look at this:

>>> from django import forms
>>> 
>>> class F(forms.Form):
...     name = forms.CharField()
... 
>>> f = F()
>>> f.is_valid
<bound method F.is_valid of <__main__.F object at 0x1010cc090>>
>>> f.is_valid()
False
>>> f = F({'name': 'Lukasz'})
>>> f.is_valid()
True

You get your boolean if you ``call`` the "is_valid" method.

On Dec 20, 2009, at 2:17 PM, BobAalsma wrote:

> I'm following the The Django Book 2.0, trying to learn Django.
> I'm on Apple OS X10.5.8, Python 2.5.1.
> I have looked at FAQ, mailing lists, etc. but did not find any
> situation looking like this.
> 
> Question:
> although all other parts seem to work as described in the book,
> the .is_valid returns an unexpected non Boolean answer - how to addres
> this?
> 
> I'll copy some of my shell log to show you the problem (following a
> part of chapter 8 of The Django Book):
>>>> from beppe.forms import ContactForm
>>>> f = ContactForm()
>>>> f = ContactForm({'subject': 'Hello', 'email': 'a...@a.nl', 'message': 
>>>> 'nice site heb je hier'})
>>>> f.is_valid
> <bound method ContactForm.is_valid of <beppe.forms.ContactForm object
> at 0x7ac990>>
>>>> f = ContactForm({'subject': 'Hello', 'email': 'a...@a.nl'})
>>>> f.is_valid
> <bound method ContactForm.is_valid of <beppe.forms.ContactForm object
> at 0x7ac970>>
>>>> f.is_bound
> True
>>>> f.errors
> {'message': [u'This field is required.']}
>>>> f = ContactForm({'subject': 'Hello', 'email': 'a...@a.nl', 'message': 
>>>> 'nice site heb je hier'})
>>>> f.errors
> {}
>>>> f.is_bound
> True
>>>> f.is_valid
> <bound method ContactForm.is_valid of <beppe.forms.ContactForm object
> at 0x7ac9f0>>
> 
> --
> 
> 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.
> 
> 

--

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