django-rest-marshmallow icon indicating copy to clipboard operation
django-rest-marshmallow copied to clipboard

fields.Pluck does not work as expected

Open vaibhavmano opened this issue 4 years ago • 0 comments

Code

class LSerializer(Schema):
    id = fields.Integer()
    last_name = fields.String()
    first_name = fields.String()

class RSerializer(Schema):
    id = fields.Integer()
    last_name = fields.Pluck(LSerializer, 'last_name')
    first_name = fields.Pluck(LSerializer, 'first_name')
    occupation = fields.String()

Response

{
    "id": 1
    "occupation": "Student"
}

Expected Response

{
    "id": 1,
    "first_name": "John",
    "last_name": "Appleseed",
    "occupation": "Student"
}

Pluck does not seem to work as expected or I'm not sure if I'm missing anything!

vaibhavmano avatar Feb 25 '21 11:02 vaibhavmano