|
@@ -373,13 +373,15 @@ class OneToOneTests(TestCase):
|
|
|
"""
|
|
|
p = Place()
|
|
|
b = UndergroundBar.objects.create()
|
|
|
- msg = (
|
|
|
- 'Cannot assign "<UndergroundBar: UndergroundBar object>": "Place" '
|
|
|
- 'instance isn\'t saved in the database.'
|
|
|
- )
|
|
|
+
|
|
|
+ # Assigning a reverse relation on an unsaved object is allowed.
|
|
|
+ p.undergroundbar = b
|
|
|
+
|
|
|
+ # However saving the object is not allowed.
|
|
|
+ msg = "save() prohibited to prevent data loss due to unsaved related object 'place'."
|
|
|
with self.assertNumQueries(0):
|
|
|
with self.assertRaisesMessage(ValueError, msg):
|
|
|
- p.undergroundbar = b
|
|
|
+ b.save()
|
|
|
|
|
|
def test_nullable_o2o_delete(self):
|
|
|
u = UndergroundBar.objects.create(place=self.p1)
|