1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #30339 -- Made Model.delete(keep_parents=True) preserves nested parent reverse relationships.

Thanks Simon Charette for the review.
This commit is contained in:
Stephen Brown
2019-04-06 21:23:52 +01:00
committed by Mariusz Felisiak
parent 29601bca9b
commit 86a3ad351e
3 changed files with 18 additions and 3 deletions

View File

@@ -212,7 +212,8 @@ class Collector:
collect_related=False,
reverse_dependency=True)
if collect_related:
parents = model._meta.parents
if keep_parents:
parents = set(model._meta.get_parent_list())
for related in get_candidate_relations_to_delete(model._meta):
# Preserve parent reverse relationships if keep_parents=True.
if keep_parents and related.model in parents: