Ticket #5868: serialization_example.py

File serialization_example.py, 408 bytes (added by tangerine, 17 years ago)

Sample

Line 
1from django import newforms as forms
2from django.utils import simplejson
3
4class 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
11form = ContactForm({'subject': '', 'sender': 'invalid_address'})
12form.is_valid()
13json = simplejson.dumps(form.errors) #this should work
Back to Top