title: How to update user password in Django Rest Framework?
body: <p>I want to ask that following code provides updating password but I want to update password after current password confirmation process. So what should I add for it? Thank you.</p>
  
  <pre><code>class UserPasswordSerializer(ModelSerializer):
  
      class Meta:
          model = User
          fields = [
              'password'
          ]
  
          extra_kwargs = {
              "password": {"write_only": True},
          }
  
      def update(self, instance, validated_data):
          for attr, value in validated_data.items():
              if attr == 'password':
                  instance.set_password(value)
              else:
                  setattr(instance, attr, value)
          instance.save()
          return instance
  </code></pre>