I want to serialize a model and include an extra field. I want to use this serializer for a list, details, and creating views. In serialializer, I use the create, update, and get_field methods to configure the logic.
class ExampleSerializer(serializers.ModelSerializer): field = serializers.CharField() class Meta: model = Example fields = ("field", ...)
When I add a new object, everything is correct (I can check the data of the user field), but when I get the object, the "field" does not exist in response.
EDIT: I want to set my own method for the serializer class to get the field. This is the best logical solution for me, and then set a custom method for the model.
Why is that? Is there a better solution for this (I don't want to use SerializerMethodField)?
source share