rsinger86/drf-flex-fields

Expand fields from view or set fields as expanded by default?

Lonyless opened this issue · 1 comments

Is there any way to expand fields from the view or set some fields as expanded by default?

Found out you can modify the expanded fields manually by overriding get_serializer method on view, dont know if it is a good practice tho (probably not)

def get_serializer(self, *args, **kwargs):
        kwargs['expand'] = ['field_to_be_expanded']
        return super().get_serializer(*args, **kwargs)