Ticket #5868: serialization_example.py
File serialization_example.py, 408 bytes (added by , 17 years ago) |
---|
Line | |
---|---|
1 | from django import newforms as forms |
2 | from django.utils import simplejson |
3 | |
4 | class ContactForm(forms.Form): |
5 | subject = forms.CharField(max_length=100) |
6 | message = forms.CharField() |
7 | sender = forms.EmailField() |
8 | cc_myself = forms.BooleanField(required=False) |
9 | |
10 | |
11 | form = ContactForm({'subject': '', 'sender': 'invalid_address'}) |
12 | form.is_valid() |
13 | json = simplejson.dumps(form.errors) #this should work |