From 6754be48ec942c3c287f4cca9e6809c999a7dfeb Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 17 Dec 2007 06:02:35 +0000 Subject: [PATCH] Generic relations should not try to drop their related table in "sqlreset". Fixed #3480. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6921 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management/sql.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/django/core/management/sql.py b/django/core/management/sql.py index 43918ef1c2..767a2dbbfb 100644 --- a/django/core/management/sql.py +++ b/django/core/management/sql.py @@ -116,6 +116,7 @@ def sql_delete(app, style): "Returns a list of the DROP TABLE SQL statements for the given app." from django.db import connection, models, get_introspection_module from django.db.backends.util import truncate_name + from django.contrib.contenttypes import generic introspection = get_introspection_module() # This should work even if a connection isn't available @@ -179,6 +180,8 @@ def sql_delete(app, style): for model in app_models: opts = model._meta for f in opts.many_to_many: + if isinstance(f.rel, generic.GenericRel): + continue if cursor and table_name_converter(f.m2m_db_table()) in table_names: output.append("%s %s;" % (style.SQL_KEYWORD('DROP TABLE'), style.SQL_TABLE(qn(f.m2m_db_table()))))