diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py index edff51a56a..e877daa4e6 100644 --- a/django/db/models/sql/subqueries.py +++ b/django/db/models/sql/subqueries.py @@ -122,7 +122,7 @@ class UpdateQuery(Query): 'Cannot update model field %r (only non-relations and ' 'foreign keys permitted).' % field ) - if model is not self.get_meta().model: + if model is not self.get_meta().concrete_model: self.add_related_update(model, field, val) continue values_seq.append((field, model, val)) diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py index 5fdfbfb6bf..50d2c57dd4 100644 --- a/tests/proxy_models/tests.py +++ b/tests/proxy_models/tests.py @@ -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