summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-07-28 01:32:46 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-07-28 01:32:46 +0000
commit19c7db005823efc2da73ca3bcb37ee15451589c8 (patch)
treea2b90e7750141317eb41eabcae5c17035752a39a /django
parent55ba38f9d26347a68fd25c32ea62d8265f96a176 (diff)
Fixed #7853 -- Fixed another case of deleting inherited models with foreign key
references. Thanks to Russell for the test case that demonstrated the problem. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8128 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/models/query.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 92395a3c4a..7f9fc3e5d9 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -835,11 +835,15 @@ def delete_objects(seen_objs):
del_query.delete_batch_related(pk_list)
update_query = sql.UpdateQuery(cls, connection)
- for field in cls._meta.fields:
+ for field, model in cls._meta.get_fields_with_model():
if (field.rel and field.null and field.rel.to in seen_objs and
filter(lambda f: f.column == field.column,
field.rel.to._meta.fields)):
- update_query.clear_related(field, pk_list)
+ if model:
+ sql.UpdateQuery(model, connection).clear_related(field,
+ pk_list)
+ else:
+ update_query.clear_related(field, pk_list)
# Now delete the actual data.
for cls in ordered_classes: