Commits

Waldemar Kornewald  committed f2c0343

fixed deletion of models with self-referencing ForeignKeys

  • Participants
  • Parent commits 9c67d36

Comments (0)

Files changed (2)

File tests/not_return_sets.py

-from .testmodels import FieldsWithOptionsModel, OrderedModel
+from .testmodels import FieldsWithOptionsModel, OrderedModel, SelfReferenceModel
 import datetime
 from django.test import TestCase
 from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
             'itachi@uchia.com', 'rasengan@naruto.com', ]).delete()
         self.assertEquals(FieldsWithOptionsModel.objects.count(), 2)
 
+    def test_selfref_deletion(self):
+        entity = SelfReferenceModel()
+        entity.save()
+        entity.delete()
+
     def test_foreign_key_fetch(self):
         # test fetching the ForeignKey
         ordered_instance = OrderedModel.objects.get(priority=2)

File tests/testmodels.py

 
 class DecimalModel(models.Model):
     decimal = models.DecimalField(max_digits=9, decimal_places=2)
+
+class SelfReferenceModel(models.Model):
+    ref = models.ForeignKey('self', null=True)