add additional data in serializer django
class getEmpDcSerializer(serializers.ModelSerializer):
Available = serializers.SerializerMethodField() # add field
Assign = serializers.SerializerMethodField() # add field
class Meta:
model = emp_details
fields = ('emp_id','emp_dc_id','emp_first_name','emp_last_name','emp_role_id', 'Available', 'Assign')
def get_Available(self, obj):
# here write the logic to compute the value based on object
return 1
def get_Assign(self, obj):
# here write the logic to compute the value based on object
return 2