Skip to content

Followup to set_context removal - #7076

Merged
lovelydinosaur merged 4 commits into
encode:masterfrom
rpkilby:unique-together-updates
Dec 11, 2019
Merged

lovelydinosaur merged 4 commits into
encode:masterfrom
rpkilby:unique-together-updates

Conversation

@rpkilby

@rpkilby rpkilby commented Dec 5, 2019

Copy link
Copy Markdown
Contributor

Hi @tomchristie. Just a review/followup for #7062.

  • Bump deprecation from 3.12 to 3.13 to be inline with our stated deprecation policy.
  • Raise RemovedInDRF313Warning instead of DeprecationWarning.
  • In some methods, pass the serializer instead of the model instance. This is necessary in order to correctly handle field source mappings (will followup in a separate PR). Also, this signature was introduced in Drop set_context() #7062, so breaking it now isn't an API breakage.
  • Change instance = getattr(serializer, 'instance', None) to just serializer.instance. The BaseSerializer declares instance, so I'm not aware of a case where it wouldn't exist.
  • Remove the validator .serializer_field, which is a holdover from set_context.

- Use `RemovedInDRF313Warning` instead of DeprecationWarning
- Update to follow deprecation policy
The `UniqueTogetherValidator` may need to access attributes on the
serializer instead of just the model instance. For example, this is
useful for handling field sources.
@lovelydinosaur

Copy link
Copy Markdown
Member

Thanks!

@lovelydinosaur
lovelydinosaur merged commit de9f1d5 into encode:master Dec 11, 2019
@rpkilby
rpkilby deleted the unique-together-updates branch December 11, 2019 09:56
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
* Raise framework-specific deprecation warnings

- Use `RemovedInDRF313Warning` instead of DeprecationWarning
- Update to follow deprecation policy

* Pass serializer instead of model to validator

The `UniqueTogetherValidator` may need to access attributes on the
serializer instead of just the model instance. For example, this is
useful for handling field sources.

* Fix framework deprecation warning in test

* Remove outdated validator attribute
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
* Raise framework-specific deprecation warnings

- Use `RemovedInDRF313Warning` instead of DeprecationWarning
- Update to follow deprecation policy

* Pass serializer instead of model to validator

The `UniqueTogetherValidator` may need to access attributes on the
serializer instead of just the model instance. For example, this is
useful for handling field sources.

* Fix framework deprecation warning in test

* Remove outdated validator attribute
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.

2 participants