'Returns a new QuerySet instance that will select objects with a
FOR UPDATE lock.'

def select_for_update(self, **kwargs):

    nowait = kwargs.pop('nowait', False)
    obj = self._clone()
    obj.query.select_for_update = True
    obj.query.select_for_update_nowait = nowait
    return obj
