I need to add a static field to my serializer. It should always return the same value regardless of the object passed. Currently, I have implemented it like this:
class QuestionSerializer(serializers.ModelSerializer): type = serializers.SerializerMethodField() @staticmethod def get_type(obj): return 'question' class Meta: model = Question fields = ('type',)
But is there an easier way to do this without SerializerMethodField ?
source share