I had similar problems, so I took the code I was doing before and improved it. It actually ended in a full-fledged python SpitEat serialization platform. You can download it here . The documentation is not very good yet, so here is the code you should use to serialize your stuff:
>>> from spiteat.djangosrz import DjangoModelSrz
>>> Model1Srz = DjangoModelSrz.factory(Model1)
>>> srz_instance = Model1Srz(some_obj_you_want_to_serialize)
>>> srz_instance.spit()
... {
... 'pk': <a_pk>,
... 'id': <an_id>,
... 'name': <a_name>,
... 'child': {
... 'pk': <another_pk>,
... 'id': <another_id>,
... 'field1': <a_value>,
... 'field2': <another_value>
... }
... }
, , . (, ..) ).
, , , , !
, , json :
>>> import json
>>> json_srz = json.dumps(srz_instance.spit())
, !