Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow context to be provided to get_serializer #7298

Merged
merged 2 commits into from
Apr 29, 2020

Conversation

rpkilby
Copy link
Member

@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
Member

@tomchristie tomchristie 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.

@tomchristie tomchristie merged commit e275b90 into encode:master Apr 29, 2020
@xordoquy
Copy link
Collaborator

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