From 3d918f41f50f1f1f756adbc77ed9575d6b475166 Mon Sep 17 00:00:00 2001 From: Gary Wilson Jr Date: Sun, 3 Aug 2008 03:03:46 +0000 Subject: [PATCH] Added tests for accessing nullable ForeignKey after saving and fetching from the database (refs #8093). git-svn-id: http://code.djangoproject.com/svn/django/trunk@8198 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/many_to_one_regress/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/regressiontests/many_to_one_regress/models.py b/tests/regressiontests/many_to_one_regress/models.py index 57df8f3716..b87b36cb3b 100644 --- a/tests/regressiontests/many_to_one_regress/models.py +++ b/tests/regressiontests/many_to_one_regress/models.py @@ -84,6 +84,16 @@ True >>> p.bestchild is None True +# bestchild should still be None after saving. +>>> p.save() +>>> p.bestchild is None +True + +# bestchild should still be None after fetching the object again. +>>> p = Parent.objects.get(name="Parent") +>>> p.bestchild is None +True + # Assigning None fails: Child.parent is null=False. >>> c.parent = None Traceback (most recent call last):