diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
index 9a6d499..5a5370f 100644
a
|
b
|
class Collector(object):
|
201 | 201 | for model in models: |
202 | 202 | if model in sorted_models: |
203 | 203 | continue |
204 | | dependencies = self.dependencies.get(model) |
| 204 | # Dependencies keys are not proxy models |
| 205 | base_model = model._meta.proxy and model._meta.proxy_for_model or model |
| 206 | dependencies = self.dependencies.get(base_model) |
205 | 207 | if not (dependencies and dependencies.difference(sorted_models)): |
206 | 208 | sorted_models.append(model) |
207 | 209 | found = True |
diff --git a/tests/modeltests/proxy_models/models.py b/tests/modeltests/proxy_models/models.py
index c033117..7c0d899 100644
a
|
b
|
they will take data directly from the table of their base class table rather
|
4 | 4 | than using a new table of their own. This allows them to act as simple proxies, |
5 | 5 | providing a modified interface to the data from the base class. |
6 | 6 | """ |
| 7 | from django.contrib.auth.models import User as AuthUser |
7 | 8 | from django.db import models |
8 | 9 | |
9 | 10 | # A couple of managers for testing managing overriding in proxy model cases. |
… |
… |
class Improvement(Issue):
|
158 | 159 | |
159 | 160 | class ProxyImprovement(Improvement): |
160 | 161 | class Meta: |
161 | | proxy = True |
162 | | No newline at end of file |
| 162 | proxy = True |
| 163 | |
| 164 | |
| 165 | class AuthUserProxy(AuthUser): |
| 166 | class Meta: |
| 167 | proxy = True |
| 168 | |
| 169 | class Profile(models.Model): |
| 170 | user = models.ForeignKey(AuthUser) |
diff --git a/tests/modeltests/proxy_models/tests.py b/tests/modeltests/proxy_models/tests.py
index 0a46a25..226369d 100644
a
|
b
|
from models import MyPersonProxy, Abstract, OtherPerson, User, UserProxy
|
11 | 11 | from models import UserProxyProxy, Country, State, StateProxy, TrackerUser |
12 | 12 | from models import BaseUser, Bug, ProxyTrackerUser, Improvement, ProxyProxyBug |
13 | 13 | from models import ProxyBug, ProxyImprovement |
| 14 | from models import AuthUser, AuthUserProxy, Profile |
14 | 15 | |
15 | 16 | class ProxyModelTests(TestCase): |
16 | 17 | def test_same_manager_queries(self): |
… |
… |
class ProxyModelTests(TestCase):
|
312 | 313 | management.call_command('loaddata', 'mypeople.json', verbosity=0, commit=False) |
313 | 314 | p = MyPerson.objects.get(pk=100) |
314 | 315 | self.assertEqual(p.name, 'Elvis Presley') |
| 316 | |
| 317 | def test_delete_cascade_to_proxy_objects(self): |
| 318 | """ |
| 319 | Test that delete() cascades to proxy objects. Regression for #16128. |
| 320 | """ |
| 321 | proxy_joe = AuthUserProxy.objects.create() |
| 322 | joe_s_profile = Profile.objects.create(user=proxy_joe) |
| 323 | self.assertEqual(Profile.objects.count(), 1) |
| 324 | proxy_joe.delete() |
| 325 | self.assertEqual(Profile.objects.count(), 0) |