Created
September 2, 2015 13:38
-
-
Save ewjoachim/d2bf713a26911161ab7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_linked_objects(obj): | |
""" | |
Returns all the objects that would be deleted if a cascade deletion were to be done. | |
""" | |
links = [rel.get_accessor_name() for rel in obj._meta.get_all_related_objects()] | |
return [liked_obj for link in links for liked_obj in getattr(obj, link).all()] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment