Skip to content

Declaratively Expressing Asymmetric Request/Response Serializers #2898

Closed
@cancan101

Description

@cancan101

There are a number of times where I want the request serializer (ie used when sending data in a POST/PUT/PATCH) to be different from the serializer used in the response (GET and potentially responses to POST, etc).

For example, I create an object without nesting but when I GET the endpoint, related objects may be included in the response.

An example of this is GitHub's API for PRs, POSTing a PR has a minimal set of fields: https://developer.github.com/v3/pulls/#create-a-pull-request
but GETting that PR has far more fields: https://developer.github.com/v3/pulls/#get-a-single-pull-request

It would be great if DRF supported this type of functionality and did so in a declarative nature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions