Actually the test form is (I forgot to change the name) class MyForm(forms.Form): text = forms.CharField() link = forms.URLField()
On Oct 18, 4:21 pm, justind <[EMAIL PROTECTED]> wrote: > I get exactly the same thing. > > Here's what I'm entering. > > >>> import simplejson > >>> simplejson > > <module 'simplejson' from 'C:\Python25\lib\site-packages > \simplejson-2.0.3-py2.5. > egg\simplejson\__init__.pyc'>>>> from myproject.app.models import MyForm > >>> f = MyForm({'link': 'footext'}) > >>> f.errors > > {'text': [u'This field is required.'], 'link': [u'Enter a valid > URL.']} > > >>> simplejson.dumps(f.errors) > > Traceback (most recent call last): > File "<console>", line 1, in <module> > File "build\bdist.win32\egg\simplejson\__init__.py", line 238, in > dumps > File "build\bdist.win32\egg\simplejson\encoder.py", line 198, in > encode > chunks = list(chunks) > File "build\bdist.win32\egg\simplejson\encoder.py", line 421, in > _iterencode > for chunk in _iterencode_dict(o, _current_indent_level): > File "build\bdist.win32\egg\simplejson\encoder.py", line 395, in > _iterencode_d > ict > for chunk in chunks: > File "build\bdist.win32\egg\simplejson\encoder.py", line 318, in > _iterencode_l > ist > for chunk in chunks: > File "build\bdist.win32\egg\simplejson\encoder.py", line 429, in > _iterencode > o = _default(o) > File "build\bdist.win32\egg\simplejson\encoder.py", line 173, in > default > raise TypeError("%r is not JSON serializable" % (o,)) > TypeError: <django.utils.functional.__proxy__ object at 0x01182870> is > not JSON > serializable > > My test form is just: > > class PrecedenceForm(forms.Form): > text = forms.CharField() > link = forms.URLField() > > Thanks for looking. Any one have any other ideas? > > On Oct 18, 4:07 pm, TiNo <[EMAIL PROTECTED]> wrote: > > > Could you try this with simplejson not bundled with Django? If that works > > this is probably a bug in the version bundled with Django. > > > On Sat, Oct 18, 2008 at 6:58 PM, justind <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > No one has any ideas? > > > > The code I'm actually using in my view is almost identical to the > > > validage_contact view from > > >http://toys.jacobian.org/presentations/2007/oscon/tutorial/(single > > > slide: > > >http://toys.jacobian.org/presentations/2007/oscon/tutorial/images/dja... > > > ) > > > and I'm using the JsonResponse function from those slides as well. > > > > Has something changed since these were published? Is this a bug? > > > > On Oct 17, 4:55 pm, "[EMAIL PROTECTED]" > > > <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > > I'm having a hard time understanding why Django won't let me serialize > > > > a dictionary of form errors. Can anyone explain why Django throws an > > > > error if I try to serialize someform.errors, even if I copy it into a > > > > plain dictionary? > > > > > #!/usr/bin/env python > > > > from django.utils import simplejson > > > > from project.main.models import SampleForm > > > > > test = {} > > > > simplejson.dumps(test) # works > > > > > test = {'key': [u"value"]} > > > > simplejson.dumps(test) # works > > > > > # suppose SampleForms wants a text and url field > > > > # I just give it a text field to test > > > > form = SampleForm({"text": "sample text"}) > > > > d = {} # make a new dictionary > > > > # update d so we're working with a plain dictionary > > > > d.update(f.errors) > > > > type(d) # returns dict > > > > > # fails: <django.utils.functional.__proxy__ object at 0x00C83810> > > > > # isnotJSONserializable > > > > simplejson.dumps(d) --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---