Re: is not JSON serializable - again
Well I got it to work by what you said. Here is my example for those that might come across this thread: if errors or request.POST.has_key('preview'): response_dict = {} datetime_now = datetime.datetime.now() comment = errors and '' or manipulator.get_comment(new_data) response_dict.update({ 'commentuser': str(comment.person_name), 'comment': str(comment.comment), 'hash': str(security_hash), 'success': True, 'year': datetime_now.year, 'month': str(datetime_now.strftime("%b")), 'day': datetime_now.strftime("%d") }) if xhr: return HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript') else: return render_to_response('comments/free_preview.html', { 'comment': comment, 'comment_form': forms.FormWrapper(manipulator, new_data, errors), 'options': options, 'target': target, 'hash': security_hash, }, context_instance=RequestContext(request)) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: is not JSON serializable - again
Funny, I literally just finished debugging the same error.If you inspect the traceback you should see which dict element wouldn't serialize. Just walk up the traceback stack and inspect the locals. The bottom couple of stack frames will be within the JSON default handler (which generates the ever so helpful exception :P ), but a few frames up you should see a local that contains the name of the dict element that the serializer was processing. Cheers,~olOn 11/6/06, timc3 <[EMAIL PROTECTED]> wrote: I get a pop-up error saying "internal server error" - which my_javascript_ is handling and displaying.The full error in the page returned is:Exception Type:TypeErrorException Value: t: t... is not JSON serializableException Location:/usr/lib/python2.4/site-packages/django/utils/simplejson/encoder.py indefault, line 258Then I get a traceback --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: is not JSON serializable - again
I get a pop-up error saying "internal server error" - which my javascript is handling and displaying. The full error in the page returned is: Exception Type: TypeError Exception Value: t: t... is not JSON serializable Exception Location: /usr/lib/python2.4/site-packages/django/utils/simplejson/encoder.py in default, line 258 Then I get a traceback --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: is not JSON serializable - again
What specifically does the error message say is not JSON serializable? Try setting it to be a string in the response dict... For example: if errors or request.POST.has_key('preview'): response_dict = {} # datetime_now = datetime.datetime.now() datetime_now = str(datetime.datetime.now()) ... etc... Rachel --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---