Should I use Django manager for custom model serialization?

<opinion> I probably wouldn’t use a manager to perform any function not related to a query - but that’s just me. YMMV. In this specific case, I’d be more inclined to make this a general utility function capable of being used with multiple models.</opinion>

As far as using non-JSON serializers, the loaddata.py and dumpdata.py management commands are capable of importing and exporting data in multiple formats - it uses the built-in serializers for that. You can look at them to see how they work.

1 Like