summaryrefslogtreecommitdiff
path: root/tests/modeltests/update_only_fields
diff options
context:
space:
mode:
authorAndrei Antoukh <niwi@niwi.be>2012-07-05 16:39:19 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-07-05 16:43:28 +0300
commit0f49b2bce2d5b3c5891c8a329bab7dffe16fc79b (patch)
treed7ef224390b349f5d8432673ba5ec2f4e225a0a6 /tests/modeltests/update_only_fields
parente4a1407a9cf35e6449136c22647a58cb14451e7a (diff)
Fixed #18362 - Made model.save() update_fields accept attnames
Diffstat (limited to 'tests/modeltests/update_only_fields')
-rw-r--r--tests/modeltests/update_only_fields/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/modeltests/update_only_fields/tests.py b/tests/modeltests/update_only_fields/tests.py
index e843bd7ab9..bce53ca621 100644
--- a/tests/modeltests/update_only_fields/tests.py
+++ b/tests/modeltests/update_only_fields/tests.py
@@ -55,6 +55,14 @@ class UpdateOnlyFieldsTests(TestCase):
self.assertEqual(e3.name, 'Ian')
self.assertEqual(e3.profile, profile_receptionist)
+ with self.assertNumQueries(1):
+ e3.profile = profile_boss
+ e3.save(update_fields=['profile_id'])
+
+ e4 = Employee.objects.get(pk=e3.pk)
+ self.assertEqual(e4.profile, profile_boss)
+ self.assertEqual(e4.profile_id, profile_boss.pk)
+
def test_update_fields_inheritance_with_proxy_model(self):
profile_boss = Profile.objects.create(name='Boss', salary=3000)
profile_receptionist = Profile.objects.create(name='Receptionist', salary=1000)