[Django]-Rest Framework Serializer Method Field

6👍

SerializerMethodField is read-only field. From the docs:

Read-only fields are included in the API output, but should not be
included in the input during create or update operations. Any
‘read_only’ fields that are incorrectly included in the serializer
input will be ignored.

If order_date realeted with some model field, you can just use DateField with source argument:

order_date = serializers.DateField(source='model_field_name')

Leave a comment