Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #18002 -- Fixed typo in attribute name in ReverseSingleRelatedO…


git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 844e56e commit 2cd516002d43cdc09741618f0a0db047ee6d78fd @claudep claudep committed
2  django/db/models/fields/
@@ -364,7 +364,7 @@ def __get__(self, instance, instance_type=None):
def __set__(self, instance, value):
if instance is None:
- raise AttributeError("%s must be accessed via instance" %
+ raise AttributeError("%s must be accessed via instance" %
# If null=True, we can assign null here, but otherwise the value needs
# to be an instance of the related class.
4 tests/regressiontests/many_to_one_regress/
@@ -58,6 +58,10 @@ def test_fk_assignment_and_related_object_cache(self):
self.assertRaises(ValueError, Child, 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.
p = Parent.objects.get(name="Parent")
c = Child(parent=p)

0 comments on commit 2cd5160

Please sign in to comment.
Something went wrong with that request. Please try again.