def change(obj, **changed_fields):
obj_field_names = {<EOL>field.name for field in obj._meta.fields<EOL>} | {<EOL>field.attname for field in obj._meta.fields<EOL>} | {'<STR_LIT>'}<EOL>for field_name, value in changed_fields.items():<EOL><INDENT>if field_name not in obj_field_names:<EOL><INDENT>raise ValueError("<STR_LIT>".format(field_name))<EOL><DEDENT>setattr(obj, field_name, value)<EOL><DEDENT>return obj<EOL>
Changes a given `changed_fields` on object and returns changed object.