Skip to content

Allow context to be provided to get_serializer#7298

Merged
lovelydinosaur merged 2 commits into
encode:masterfrom
rpkilby:serializer-context
Apr 29, 2020
Merged

Allow context to be provided to get_serializer#7298
lovelydinosaur merged 2 commits into
encode:masterfrom
rpkilby:serializer-context

Conversation

@rpkilby
Copy link
Copy Markdown
Contributor

@rpkilby rpkilby commented Apr 29, 2020

Allows the context kwarg to be provided to the call to get_serializer. Currently a given context is overridden by the get_serializer_context result.

refs #6956

Copy link
Copy Markdown
Contributor

@lovelydinosaur lovelydinosaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a nice little improvement, yup.

@lovelydinosaur lovelydinosaur merged commit e275b90 into encode:master Apr 29, 2020
@xordoquy
Copy link
Copy Markdown
Contributor

We should put a few words in the release log about possible breaking change here. Provided context is passed in arguments:

  • kwargs['context'] = self.get_serializer_context() discards the provided context and uses get_serializer_context
  • kwargs.setdefault('context', self.get_serializer_context()) uses the provided context and discards get_serializer_context

@rpkilby rpkilby added this to the 3.12 Release milestone Apr 29, 2020
@rpkilby rpkilby deleted the serializer-context branch April 29, 2020 16:21
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
* Test generics serializer behavior

* Allow context to be provided to get_serializer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants