Is it possible to check how many rows were deleted by the query?
queryset = MyModel.object.filter(foo=bar) queryset.delete() deleted = ...
Or use transactions to do this?
@transaction.commit_on_success def delete_some_rows(): queryset = MyModel.object.filter(foo=bar) deleted = queryset.count() queryset.delete()
PHP + MySQL example:
mysql_query('DELETE FROM mytable WHERE id < 10'); printf("Records deleted: %d\n", mysql_affected_rows());
django mysql django-models django-orm
Tomasz wysocki
source share