Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions immutablemodel/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# encoding: utf-8
from django.db import models
from django.db import models, router
from django.db.models.deletion import Collector
from django.utils import six


Expand Down Expand Up @@ -194,7 +195,12 @@ def delete(self):
raise CantDeleteImmutableException(
"%s is immutable and cannot be deleted" % self
)
self._deleting_immutable_model = True
collector = Collector(using=router.db_for_write(self.__class__, instance=self))
collector.collect([self], collect_related=False)
collector.sort()
for model, instances in collector.data.items():
for instance in instances:
instance._deleting_immutable_model = True
super(ImmutableModel, self).delete()
delattr(self, '_deleting_immutable_model')

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name = 'django-immutablemodel',
version = '0.3.4',
version = '0.3.5',
description="A base class for Django to allow immutable fields on Models",
long_description=README + '\n\n' + NEWS,
classifiers=[
Expand Down