Skip to content

Drop set_context() - #7062

Merged
lovelydinosaur merged 3 commits into
masterfrom
drop-set-context
Dec 3, 2019
Merged

lovelydinosaur merged 3 commits into
masterfrom
drop-set-context

Conversation

@lovelydinosaur

Copy link
Copy Markdown
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?

@carltongibson carltongibson left a comment

Copy link
Copy Markdown
Collaborator

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.

@lovelydinosaur

Copy link
Copy Markdown
Member Author

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

@rpkilby

rpkilby commented Nov 23, 2019

Copy link
Copy Markdown
Contributor

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

@lovelydinosaur
lovelydinosaur merged commit 070cff5 into master Dec 3, 2019
@lovelydinosaur
lovelydinosaur 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

Development

Successfully merging this pull request may close these issues.

4 participants