Skip to content

Drop set_context() #7062

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

Merged
merged 3 commits into from
Dec 3, 2019
Merged

Drop set_context() #7062

merged 3 commits into from
Dec 3, 2019

Conversation

tomchristie
Copy link
Member

Follow on from #6172

Drops set_context() on defaults and validators, in favour of a requires_context = True marker, which causes the serializer field to be passed as an additional argument.

What do we think about this?

@tomchristie tomchristie added this to the 3.11 Release milestone Nov 21, 2019
Copy link
Collaborator

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

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

Of the two options you mentioned in #6172 (comment), I much prefer this. (To inspecting __call__())

Looks neat at first glance. Would need calling out in the release notes, but should be simple enough to inline existing set_context() implementations.

@tomchristie
Copy link
Member Author

Sure, also it is still our regular gentle deprecation process, so not a big deal.

@rpkilby
Copy link
Member

rpkilby commented Nov 23, 2019

My brain is currently toast, but I'll try to look at this over the weekend.

@tomchristie tomchristie merged commit 070cff5 into master Dec 3, 2019
@tomchristie tomchristie deleted the drop-set-context branch December 3, 2019 11:16
bd808 added a commit to bd808/drf-friendly-errors that referenced this pull request Nov 14, 2020
In encode/django-rest-framework#7062 the API for calling DRF validators
changed to require the caller to inspect the validator instance to
determine if the validator requires a second argument at call time.
Usage with DRF >=3.11.0 requires this support.
bd808 added a commit to bd808/drf-friendly-errors that referenced this pull request Nov 14, 2020
In encode/django-rest-framework#7062 the API for calling DRF validators
changed to require the caller to inspect the validator instance to
determine if the validator requires a second argument at call time.
Usage with DRF >=3.11.0 requires this support.
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
* Do not persist the context in validators

Fixes encode#5760

* Drop set_context() in favour of 'requires_context = True'
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
* Do not persist the context in validators

Fixes encode#5760

* Drop set_context() in favour of 'requires_context = True'
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.

4 participants