-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
The logic around deleting models is incorrect if model inheritance is used.
For example:
class A(ImmutableModel):
pass
class B(A):
pass
class C(B):
pass
>>> c = C.objects.create()
>>> c.delete()
ValueError: B.a_ptr_id is immutable and cannot be changedThe delete of the C instance is fine, because the overridden c.delete() set the special flag _deleting_immutable_model = True.
When django gets to setting the B instances parent pointer however, this flag is not set (because it's a different object.
Solution
Walk the parent classes of the model being deleted and set _deleting_immutable_model = True on all of them.
Metadata
Metadata
Assignees
Labels
No labels