summaryrefslogtreecommitdiff
path: root/tests/update_only_fields/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/update_only_fields/tests.py')
-rw-r--r--tests/update_only_fields/tests.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/update_only_fields/tests.py b/tests/update_only_fields/tests.py
index a6a5b7cb8e..43f3e1fd16 100644
--- a/tests/update_only_fields/tests.py
+++ b/tests/update_only_fields/tests.py
@@ -7,8 +7,8 @@ from .models import Account, Employee, Person, Profile, ProxyEmployee
class UpdateOnlyFieldsTests(TestCase):
msg = (
- "The following fields do not exist in this model, are m2m fields, or "
- "are non-concrete fields: %s"
+ "The following fields do not exist in this model, are m2m "
+ "fields, primary keys, or are non-concrete fields: %s"
)
def test_update_fields_basic(self):
@@ -308,3 +308,13 @@ class UpdateOnlyFieldsTests(TestCase):
profile_boss = Profile.objects.create(name="Boss", salary=3000)
with self.assertRaisesMessage(ValueError, self.msg % "non_concrete"):
profile_boss.save(update_fields=["non_concrete"])
+
+ def test_update_pk_field(self):
+ person_boss = Person.objects.create(name="Boss", gender="F")
+ with self.assertRaisesMessage(ValueError, self.msg % "id"):
+ person_boss.save(update_fields=["id"])
+
+ def test_update_inherited_pk_field(self):
+ employee_boss = Employee.objects.create(name="Boss", gender="F")
+ with self.assertRaisesMessage(ValueError, self.msg % "id"):
+ employee_boss.save(update_fields=["id"])