def obj_to_dict(obj):
    data = serializers.serialize('json', [obj, ])
    struct = json.loads(data)[0]
    response = struct['fields']
    response[u'id'] = response[u'pk'] = struct['pk']
    response[u'model'] = struct['model']
    # JSONField doesn't get serialized by `serialize`
    for f in obj._meta.fields:
        if type(f) == JSONField:
            e = getattr(obj, f.name)
            # postgres < 9.3 support
            while type(e) == unicode:
                e = json.loads(e)
            response[unicode(f.name)] = e
    return response
serializes obj for a JSON friendly version
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/models.py/obj_to_dict