summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/core/management.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/core/management.py b/django/core/management.py
index ce86e9959a..f53a45e96f 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -191,8 +191,9 @@ def get_sql_delete(mod):
# Close database connection explicitly, in case this output is being piped
# directly into a database client, to avoid locking issues.
- cursor.close()
- db.db.close()
+ if cursor is not None:
+ cursor.close()
+ db.db.close()
return output[::-1] # Reverse it, to deal with table dependencies.
get_sql_delete.help_doc = "Prints the DROP TABLE SQL statements for the given model module name(s)."