              if hasattr(validator, 'set_context'):
                  validator.set_context(self)
  
              try:
                  validator(value)
              except ValidationError as exc:
                  # If the validation error contains a mapping of fields to
                  # errors then simply raise it immediately rather than
                  # attempting to accumulate a list of errors.
                  if isinstance(exc.detail, dict):
 
</s> remove     def set_context(self, serializer):
        """
        This hook is called by the serializer instance,
        prior to the validation call being made.
        """
        # Determine the existing instance, if this is an update operation.
        self.instance = getattr(serializer, 'instance', None)

    def enforce_required_fields(self, attrs):
 </s> add     def enforce_required_fields(self, attrs, instance): </s> remove     def filter_queryset(self, attrs, queryset):
 </s> add     def filter_queryset(self, attrs, queryset, instance): </s> remove         if self.instance is not None:
 </s> add         if instance is not None:
                if getattr(validator, 'requires_context', False):
                    validator(value, self)
                else:
                    validator(value)
              if hasattr(validator, 'set_context'):
                  validator.set_context(self)
  
              try:
                if getattr(validator, 'requires_context', False):
                    validator(value, self)
                else:
                    validator(value)
              except ValidationError as exc:
                  # If the validation error contains a mapping of fields to
                  # errors then simply raise it immediately rather than
                  # attempting to accumulate a list of errors.
                  if isinstance(exc.detail, dict):
keep keep keep keep replace keep keep keep keep keep
 Drop `set_context()` (#7062)

* Do not persist the context in validators

Fixes encode/django-rest-framework#5760

* Drop set_context() in favour of 'requires_context = True' 
rest_framework/fields.py