diff --git a/django_mongodb/compiler.py b/django_mongodb/compiler.py index 46d3afaab..55749ede4 100644 --- a/django_mongodb/compiler.py +++ b/django_mongodb/compiler.py @@ -693,7 +693,13 @@ def collection_name(self): class SQLDeleteCompiler(compiler.SQLDeleteCompiler, SQLCompiler): def execute_sql(self, result_type=MULTI): cursor = Cursor() - cursor.rowcount = self.build_query().delete() + try: + query = self.build_query() + except EmptyResultSet: + rowcount = 0 + else: + rowcount = query.delete() + cursor.rowcount = rowcount return cursor def check_query(self):