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/django-master-class.081.png > ) > 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 -~----------~----~----~----~------~----~------~--~---