code: def change(obj, **changed_fields):
      
      obj_field_names = {
          field.name for field in obj._meta.fields
      } | {
          field.attname for field in obj._meta.fields
      } | {'pk'}
  
      for field_name, value in changed_fields.items():
          if field_name not in obj_field_names:
              raise ValueError("'{}' is an invalid field name".format(field_name))
          setattr(obj, field_name, value)
      return obj
docs: Changes a given `changed_fields` on object and returns changed object.