Search code examples
pythondjangoserializationdjango-piston

django-piston : Overriding default serialization in emitters


I am currently writing an API for a django project, and using django-piston for this. However, I need to customize the way certain base types are serialized.

More precisely, my models are subclassed from a special Model class, which inherits from django.db.models.base.ModelBase, but cannot be serialized as regular django models ... Therefore, I would like to override the serializer for all subclasses of this special Model class.

I don't know piston well ... I've looked at the code, and the mapping type->serializer (for base types) seems to be hard-coded.

Does anybody know if there is a standard way to override it ???


Solution

  • Ok ... I couldn't have it working, so I took some code that I had written myself some time ago, made it cleaner, it ended-up in a full Python serialization framework SpitEat. I have begun writing some documentation, but it's a work in progress.

    I have given-up using piston, since it is not the first time it disappoints me by its lack of flexibility on (de)serialization operations.

    SpitEat aims to be fully customizable, (by seeing serialization from a more abstract point of view than just "django objects") and provides serializers for Django, tested, but not so well documented yet, and with features that are still missing (again it is a work in progress).