mirror of https://github.com/django/django.git
Refs #18012 -- Removed special casing for proxy models deletion.
This isn't required anymore now that reverse foreign keys from proxy models are propagated to their concrete model.
This commit is contained in:
parent
6c9f37ea9e
commit
8bdfabed65
|
@ -1,5 +1,4 @@
|
|||
from collections import Counter, OrderedDict
|
||||
from itertools import chain
|
||||
from operator import attrgetter
|
||||
|
||||
from django.db import IntegrityError, connections, transaction
|
||||
|
@ -53,18 +52,10 @@ def DO_NOTHING(collector, field, sub_objs, using):
|
|||
|
||||
|
||||
def get_candidate_relations_to_delete(opts):
|
||||
# Collect models that contain candidate relations to delete. This may include
|
||||
# relations coming from proxy models.
|
||||
candidate_models = {opts}
|
||||
candidate_models = candidate_models.union(opts.concrete_model._meta.proxied_children)
|
||||
# For each model, get all candidate fields.
|
||||
candidate_model_fields = chain.from_iterable(
|
||||
opts.get_fields(include_hidden=True) for opts in candidate_models
|
||||
)
|
||||
# The candidate relations are the ones that come from N-1 and 1-1 relations.
|
||||
# N-N (i.e., many-to-many) relations aren't candidates for deletion.
|
||||
return (
|
||||
f for f in candidate_model_fields
|
||||
f for f in opts.get_fields(include_hidden=True)
|
||||
if f.auto_created and not f.concrete and (f.one_to_one or f.one_to_many)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue