MCPcopy
hub / github.com/django/django / sort

Method sort

django/db/models/deletion.py:448–464  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

446 yield model, obj
447
448 def sort(self):
449 sorted_models = []
450 concrete_models = set()
451 models = list(self.data)
452 while len(sorted_models) < len(models):
453 found = False
454 for model in models:
455 if model in sorted_models:
456 continue
457 dependencies = self.dependencies.get(model._meta.concrete_model)
458 if not (dependencies and dependencies.difference(concrete_models)):
459 sorted_models.append(model)
460 concrete_models.add(model._meta.concrete_model)
461 found = True
462 if not found:
463 return
464 self.data = {model: self.data[model] for model in sorted_models}
465
466 def delete(self):
467 # sort instance collections

Callers 10

deleteMethod · 0.95
learn_cache_keyFunction · 0.45
set_choicesMethod · 0.45
ordered_formsMethod · 0.45
get_app_listMethod · 0.45
get_namesMethod · 0.45
test_11_sortingMethod · 0.45
test_sortMethod · 0.45

Calls 4

getMethod · 0.45
differenceMethod · 0.45
appendMethod · 0.45
addMethod · 0.45

Tested by 4

get_namesMethod · 0.36
test_11_sortingMethod · 0.36
test_sortMethod · 0.36