Considering those classes:
class Foo(models.Model):
pass
class Bar(models.Model):
foo = models.ForeignKey(Foo)
class Baz(models.Model):
bar = models.ForeignKey(Bar)
class XXX(models.Model):
field = models.ForeignKey(field_related_to_FOO_somehow)
...
Given an instance foo=Foo.objects.get(...)
that a user want to delete, i want to provide him a view of all the objects he's about to delete. Thus, how can i retrieve all the instances of Bar
, Baz
and all other related objects XXX
that will be deleted in cascade if the user confirm?