          model = UniquenessModel
  
  
  class AnotherUniquenessModel(models.Model):
      code = models.IntegerField(unique=True)
  
  
  class AnotherUniquenessSerializer(serializers.ModelSerializer):
      class Meta:
 
</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] </s> remove         self.field_name = serializer_field.source_attrs[0]
 </s> add         self.field_name = serializer_field.source_attrs[-1]
class RelatedModel(models.Model):
    user = models.OneToOneField(UniquenessModel, on_delete=models.CASCADE)
    email = models.CharField(unique=True, max_length=80)


class RelatedModelSerializer(serializers.ModelSerializer):
    username = serializers.CharField(source='user.username',
        validators=[UniqueValidator(queryset=UniquenessModel.objects.all())])  # NOQA

    class Meta:
        model = RelatedModel
        fields = ('username', 'email')


          model = UniquenessModel
  
  
class RelatedModel(models.Model):
    user = models.OneToOneField(UniquenessModel, on_delete=models.CASCADE)
    email = models.CharField(unique=True, max_length=80)


class RelatedModelSerializer(serializers.ModelSerializer):
    username = serializers.CharField(source='user.username',
        validators=[UniqueValidator(queryset=UniquenessModel.objects.all())])  # NOQA

    class Meta:
        model = RelatedModel
        fields = ('username', 'email')


  class AnotherUniquenessModel(models.Model):
      code = models.IntegerField(unique=True)
  
  
  class AnotherUniquenessSerializer(serializers.ModelSerializer):
      class Meta:
keep keep add keep keep 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