mirror of https://github.com/django/django.git
Fixed #18002 -- Fixed typo in attribute name in ReverseSingleRelatedObjectDescriptor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17904 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
844e56e21a
commit
2cd516002d
|
@ -364,7 +364,7 @@ class ReverseSingleRelatedObjectDescriptor(object):
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
if instance is None:
|
if instance is None:
|
||||||
raise AttributeError("%s must be accessed via instance" % self._field.name)
|
raise AttributeError("%s must be accessed via instance" % self.field.name)
|
||||||
|
|
||||||
# If null=True, we can assign null here, but otherwise the value needs
|
# If null=True, we can assign null here, but otherwise the value needs
|
||||||
# to be an instance of the related class.
|
# to be an instance of the related class.
|
||||||
|
|
|
@ -58,6 +58,10 @@ class ManyToOneRegressionTests(TestCase):
|
||||||
self.assertRaises(ValueError, Child, name='xyzzy', parent=None)
|
self.assertRaises(ValueError, Child, name='xyzzy', parent=None)
|
||||||
self.assertRaises(ValueError, Child.objects.create, name='xyzzy', parent=None)
|
self.assertRaises(ValueError, Child.objects.create, name='xyzzy', parent=None)
|
||||||
|
|
||||||
|
# Trying to assign to unbound attribute raises AttributeError
|
||||||
|
self.assertRaisesRegexp(AttributeError, "must be accessed via instance",
|
||||||
|
Child.parent.__set__, None, p)
|
||||||
|
|
||||||
# Creation using keyword argument should cache the related object.
|
# Creation using keyword argument should cache the related object.
|
||||||
p = Parent.objects.get(name="Parent")
|
p = Parent.objects.get(name="Parent")
|
||||||
c = Child(parent=p)
|
c = Child(parent=p)
|
||||||
|
|
Loading…
Reference in New Issue