  from django.test import TestCase
  
  from rest_framework import serializers
  
  
  def dedent(blocktext):
      return '\n'.join([line[12:] for line in blocktext.splitlines()[1:-1]])
 
</s> remove         self.field_name = serializer_field.source_attrs[0]
 </s> add         self.field_name = serializer_field.source_attrs[-1] </s> remove         self.field_name = serializer.fields[self.field].source_attrs[0]
        self.date_field_name = serializer.fields[self.date_field].source_attrs[0]
 </s> add         self.field_name = serializer.fields[self.field].source_attrs[-1]
        self.date_field_name = serializer.fields[self.date_field].source_attrs[-1]
from rest_framework.validators import UniqueValidator
  from django.test import TestCase
  
  from rest_framework import serializers
from rest_framework.validators import UniqueValidator
  
  
  def dedent(blocktext):
      return '\n'.join([line[12:] for line in blocktext.splitlines()[1:-1]])
keep keep add keep keep keep keep
 Fix #3844, refine validator for fields with <source=> kwargs

When serializers has fields with something like `source=user.email`, the
uniqueness validator should check `email` field instead of `user`, cause
`user` is a model object. 
tests/test_validators.py