Admin Delete Page Incorrectly Counts Related Objects
In the case where we're deleting an object (A) that has dependent foreign object (B) that points to it, and a different dependent foreign object (C) that also has B as a dependent foreign object, the admin will incorrectly double count this object. As an example:
class Spam(models.Model):
pass
class Egg(models.Model):
spam = ForeignKey(Spam)
class Shrubbery(models.Model):
spam = ForeignKey(Spam)
egg = ForeignKey(Egg)
spam = Spam.objects.create()
egg = Egg.objects.create(spam=spam)
shrubbery = Shrubbery.objects.create(spam=spam, egg=egg)
If we issue a delete on an instance of Spam in this case, the admin will state that we are deleting 2 instances of Shrubbery, even though we are really only deleting 1 instance of Shrubbery that is attached both directly to the instance of Spam, and to the instance of Egg that is a dependent object of spam.
Change History (5)
Component: |
Uncategorized →
contrib.admin
|
Triage Stage: |
Unreviewed →
Accepted
|
Type: |
Uncategorized →
Bug
|
Owner: |
changed from nobody to Sergey Fedoseev
|
Status: |
new →
assigned
|
Resolution: |
→ fixed
|
Status: |
assigned →
closed
|
Reproduced at 0f2c2c104b51a226525d7e7baa65ea1fd27e994f. The original feature was added in 302145328560ded44bcfded8a67a1e7df08b411b.