diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
index 730847e..d8bb8f2 100644
a
|
b
|
def collect(self, objs, source=None, nullable=False, collect_related=True,
|
154 | 154 | |
155 | 155 | model = new_objs[0].__class__ |
156 | 156 | |
157 | | # Recursively collect parent models, but not their related objects. |
158 | | # These will be found by meta.get_all_related_objects() |
159 | | for parent_model, ptr in model._meta.parents.iteritems(): |
| 157 | # Recursively collect concrete model's parent models, but not their |
| 158 | # related objects. These will be found by meta.get_all_related_objects() |
| 159 | concrete_model = model._meta.concrete_model |
| 160 | for ptr in concrete_model._meta.parents.itervalues(): |
160 | 161 | if ptr: |
161 | 162 | parent_objs = [getattr(obj, ptr.name) for obj in new_objs] |
162 | 163 | self.collect(parent_objs, source=model, |
diff --git a/tests/modeltests/proxy_model_inheritance/models.py b/tests/modeltests/proxy_model_inheritance/models.py
index e69de29..ef9ac6b 100644
a
|
b
|
|
| 1 | |
| 2 | from django.db import models |
| 3 | |
| 4 | |
| 5 | class ConcreteModel(models.Model): |
| 6 | pass |
| 7 | |
| 8 | class ConcreteModelSubclass(ConcreteModel): |
| 9 | pass |
| 10 | |
| 11 | class ConcreteModelSubclassProxy(ConcreteModelSubclass): |
| 12 | class Meta: |
| 13 | proxy = True |
diff --git a/tests/modeltests/proxy_model_inheritance/tests.py b/tests/modeltests/proxy_model_inheritance/tests.py
index ae5ab20..94805d9 100644
a
|
b
|
|
1 | | """ |
2 | | XX. Proxy model inheritance |
3 | | |
4 | | Proxy model inheritance across apps can result in syncdb not creating the table |
5 | | for the proxied model (as described in #12286). This test creates two dummy |
6 | | apps and calls syncdb, then verifies that the table has been created. |
7 | | """ |
8 | | |
9 | 1 | from __future__ import absolute_import |
10 | 2 | |
11 | 3 | import os |
… |
… |
|
14 | 6 | from django.conf import settings |
15 | 7 | from django.core.management import call_command |
16 | 8 | from django.db.models.loading import cache, load_app |
17 | | from django.test import TransactionTestCase |
| 9 | from django.test import TestCase, TransactionTestCase |
18 | 10 | from django.test.utils import override_settings |
19 | 11 | |
| 12 | from .models import (ConcreteModel, ConcreteModelSubclass, |
| 13 | ConcreteModelSubclassProxy) |
| 14 | |
20 | 15 | |
21 | 16 | @override_settings(INSTALLED_APPS=('app1', 'app2')) |
22 | 17 | class ProxyModelInheritanceTests(TransactionTestCase): |
| 18 | """ |
| 19 | Proxy model inheritance across apps can result in syncdb not creating the table |
| 20 | for the proxied model (as described in #12286). This test creates two dummy |
| 21 | apps and calls syncdb, then verifies that the table has been created. |
| 22 | """ |
23 | 23 | |
24 | 24 | def setUp(self): |
25 | 25 | self.old_sys_path = sys.path[:] |
… |
… |
def test_table_exists(self):
|
41 | 41 | from .app2.models import NiceModel |
42 | 42 | self.assertEqual(NiceModel.objects.all().count(), 0) |
43 | 43 | self.assertEqual(ProxyModel.objects.all().count(), 0) |
| 44 | |
| 45 | class MultiTableInheritanceProxyTest(TestCase): |
| 46 | |
| 47 | def test_model_subclass_proxy(self): |
| 48 | """ |
| 49 | Deleting an instance of a model proxing a multi-table inherited subclass |
| 50 | might not cascade delete down the whole inheritance chain while doing it |
| 51 | on the proxied concrete class works (as described in #18083). |
| 52 | """ |
| 53 | instance = ConcreteModelSubclassProxy.objects.create() |
| 54 | instance.delete() |
| 55 | self.assertEqual(0, ConcreteModelSubclassProxy.objects.count()) |
| 56 | self.assertEqual(0, ConcreteModelSubclass.objects.count()) |
| 57 | self.assertEqual(0, ConcreteModel.objects.count()) |