I found this thread when I ran into the same need to create a custom serializer in DRF (2.3.x). I got it to work by making two very simple tweaks to the solution posted by Tom Christie above, and wanted to share for anyone else.
1. The serializer class simply needs a `base_fields = {}` attribute in order to successfully initialize.
2. The serialization method in DRF 2.x is actually `to_native()`, not `to_represenation()`. It will be called with the instance of the Python object to serialize.
In essence, I believe all you need is:
```
from rest_framework import serializers
class GraphSerializer(serializers.BaseSerializer):
base_fields = {}
def to_native(obj):
return obj.subgraph_to_dict()
```
Hope this helps!
- Anthony