Answers for "add additional data in serializer django"

0

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
Posted by: Guest on October-24-2021

Code answers related to "add additional data in serializer django"

Python Answers by Framework

Browse Popular Code Answers by Language