How Can I Add Field In Serializer?
Below is my serializer.py file: from rest_framework import serializers class TaskListSerializer(serializers.Serializer): id = serializers.CharField() user_id = serializer
Solution 1:
Use serializers.SerializerMethodField()
class TaskListSerializer(serializers.ModelSerializer):
complex_things = serializers.SerializerMethodField()
def get_complex_things(self, obj):
result_of_complex_things = 2 + 2
return result_of_complex_things
Post a Comment for "How Can I Add Field In Serializer?"