title: Django rest framework email validation
body: <p>I want to validate email id if already exists in the User model before registration</p>
  
  <p>This is my serializer with validation</p>
  
  <pre><code>class RegistrationSerializer(serializers.Serializer):
      username = serializers.CharField(max_length=100)
      email = serializers.EmailField()
      password = serializers.CharField(max_length=100)
  
      def validate_email(self,attrs):
              email=attrs['email']
              print email
              if email:
                      emailset = Q(email__icontains=email)
                      emailres = User.objects.filter(emailset)
                      if emailres:
                              msg = _('The email address is already taken')
                              raise serializers.ValidationError(msg)
                      else:
                              return attars
  </code></pre>
  
  <p>It is throwing error "TypeError:string indices must be integers"</p>
  
  <pre><code> email=attrs['email']
  </code></pre>
  
  <p>TypeError: string indices must be integers</p>