rest_framework_dso.serializer_helpers module

Internal serializer tools to make sure generators are properly handled in DRF.

class rest_framework_dso.serializer_helpers.ReturnGenerator(generator, serializer=None)

Bases: ReturnList

A class in the same spirit as DRF’s ReturnList / ReturnDict. It binds the origin / serializer instance with the returned data.

To pass the rendering logic, it either needs to inherit from GeneratorType, or list.

__init__(generator, serializer=None)
rest_framework_dso.serializer_helpers.peek_iterable(generator)

Take a quick look at the first item of a generator/iterable. This returns a modified iterable that contains all elements, including the peeked item.