Hi, I'm writing a simple ajax form and I'm having trouble JSON-encoding the result of Model.validate(). I always get an error similar to "'This field is required.' cannot be JSON-encoded"
To verify the posted data i populate the model I intend to save and call validate(). If there are any errors I want to JSON-encode them and send them back to the client, like this: obj = MyModel(name = request.POST.get('name', False), email = request.POST.get('name', False)) validation_errors = obj.validate() if len(validation_errors) > 0: return HttpResponse(simplejson.dumps(validation_errors), mimetype="application/javascript") I've been searching around and I found that the result of Model.validate() contains some objects of type instance that for some reason cannot be JSON-encoded. I find this all very strange, shouldn't the result of validate() contain string key-pairs? JSON-encoding this should be straightforward. Anyone has encountered this problem or could lend me a hand on this? Thank you! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---