title: TypeError: User() got an unexpected keyword argument 'confirm_password'
body: <p>I want to add <code>password</code> field and <code>confirm_password</code> field to my <code>UserSerializer</code>. I wrote a function called <code>create</code> to create a hashes password for my <code>password</code> field but before it can create the hashes password I want it to make sure that <code>confirm_password</code> and <code>password</code> are matched. The code works fine if I remove the <code>confirm_password</code> field. What is the problem?</p>
  <p>[ Updated ]</p>
  <p>My serializers.py</p>
  <pre><code># serializer define the API representation
  class UserSerializer(serializers.HyperlinkedModelSerializer):
  
      # password field
      password = serializers.CharField(
          write_only = True,
          required = True,
          help_text = 'Enter password',
          style = {'input_type': 'password'}
      )
      
      # confirm password field
      confirm_password = serializers.CharField(
          write_only = True,
          required = True,
          help_text = 'Enter confirm password',
          style = {'input_type': 'password'}
      )
  
      class Meta:
          model = User
          fields = [
              'url', 'first_name', 'last_name', 'email',
              'password', 'confirm_password', 'is_staff'
          ]
      
      def create(self, validated_data):
          if validated_data.get('password') != validated_data.get('confirm_password'):
              raise serializers.ValidationError(&quot;Those password don't match&quot;) 
  
          elif validated_data.get('password') == validated_data.get('confirm_password'):
              validated_data['password'] = make_password(
                  validated_data.get('password')
              )
  
          return super(UserSerializer, self).create(validated_data)
  </code></pre>
  <p>error I got</p>
  <pre><code>TypeError: User() got an unexpected keyword argument 'confirm_password'
  
  [20/Aug/2020 16:15:44] &quot;POST /users/ HTTP/1.1&quot; 500 168152
  </code></pre>
  <p>error I got in browser</p>
  <pre><code>TypeError at /users/
  Got a `TypeError` when calling `User.objects.create()`. This may be because you have a writable field on the serializer class that is not a valid argument to `User.objects.create()`. You may need to make the field read-only, or override the UserSerializer.create() method to handle this correctly.
  </code></pre>
  <p>I can edit the question if you need more detail. Ty!</p>