mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #25910 -- Rejected read-only property names in model constructors.
This commit is contained in:
parent
4dc74371e3
commit
16baec5c8a
2 changed files with 6 additions and 1 deletions
|
@ -18,6 +18,10 @@ class PropertyTests(TestCase):
|
|||
# The "full_name" property hasn't provided a "set" method.
|
||||
self.assertRaises(AttributeError, setattr, self.a, 'full_name', 'Paul McCartney')
|
||||
|
||||
# And cannot be used to initialize the class.
|
||||
with self.assertRaisesMessage(TypeError, "'full_name' is an invalid keyword argument"):
|
||||
Person(full_name='Paul McCartney')
|
||||
|
||||
# But "full_name_2" has, and it can be used to initialize the class.
|
||||
a2 = Person(full_name_2='Paul McCartney')
|
||||
a2.save()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue