'Updates all elements in the current QuerySet, setting all the given
fields to the appropriate values.'

def update(self, **kwargs):

    assert self.query.can_filter(), 'Cannot    update    a    query    once    a    slice    has    been    taken.'
    self._for_write = True
    query = self.query.clone(sql.UpdateQuery)
    query.add_update_values(kwargs)
    if (not transaction.is_managed(using=self.db)):
        transaction.enter_transaction_management(using=self.db)
        forced_managed = True
    else:
        forced_managed = False
    try:
        rows = query.get_compiler(self.db).execute_sql(None)
        if forced_managed:
            transaction.commit(using=self.db)
        else:
            transaction.commit_unless_managed(using=self.db)
    finally:
        if forced_managed:
            transaction.leave_transaction_management(using=self.db)
    self._result_cache = None
    return rows
