-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Currently, all the fields of the model are serialized by default. It is possible to restrict the direction of the serialization with the Field parameters load_only and dump_only.
There is a hack to get a field ignored by setting both load_only and dump_only to true.
class MySerializer(ModelSerializer):
field_to_ignore = Field(load_only=True, dump_only=True)But would be nice to have o more official and elegant way to do it. I had some ideas
Opition 1: Add a new flag to Field to make that field ignored
class MySerializer(ModelSerializer):
field_to_ignore = Field(ignore=True)Opition 2: add meta information about the fields to ignore
class MySerializer(ModelSerializer):
_ignore_fields_ = ['field_to_ignore', 'another_field_to_ignore']
...nobreconfrade
Metadata
Metadata
Assignees
Labels
No labels