1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #28820 -- Eliminated an extra query with QuerySet.update() on proxy models.

This commit is contained in:
Yan Mitrofanov
2017-11-20 18:25:01 +03:00
committed by Tim Graham
parent a5f1e5809f
commit 54e5c4a00e
2 changed files with 8 additions and 1 deletions

View File

@@ -276,6 +276,13 @@ class ProxyModelTests(TestCase):
resp = [u.name for u in UserProxy.objects.all()]
self.assertEqual(resp, ['Bruce'])
def test_proxy_update(self):
user = User.objects.create(name='Bruce')
with self.assertNumQueries(1):
UserProxy.objects.filter(id=user.id).update(name='George')
user.refresh_from_db()
self.assertEqual(user.name, 'George')
def test_select_related(self):
"""
We can still use `select_related()` to include related models in our