[Fixed]-Django Rest Framework – related fields as nested objects for GET and pk for POST only

1👍

You can use different serializer for POST and GET requests.
Override get_serializer_class

def get_serializer_class(self):
    if self.request.method == 'POST':
        return SalaryPostSerializer
    return SalaryFullSerializer

Leave a comment