0

I have a problem passing an object using pusher it gives me an error Error: new_action is not JSON serializable. I tried json.dumps(new_action) but still not working. Here is my code :

views.py:

 new_action = Action(actor=actor, verb=verb, action_object=action_object,description=description, target=target)
 new_action.save()
 p['stream_' + str(actor.username)].trigger('liveStream', {
        'new_action': new_action,
 });
 return new_action
4

1 に答える 1

0

添付のコードがわかりませんが、これを試してください:

from django.core.serializers.json import DjangoJSONEncoder

# ...

json.dumps(new_action, cls=DjangoJSONEncoder)

それが役立つことを願っています。

于 2012-10-07T14:31:11.783 に答える