diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2006-06-23 08:16:36 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2006-06-23 08:16:36 +0000 |
| commit | dc473309ef15e88a41845a52485eb6d38f819637 (patch) | |
| tree | f1f65d3ff55f18c4b6d557f1ba1bacedc6306e16 /tests/regressiontests | |
| parent | 6cbdbffc80fde098ed491dc2aea4d1f3105b3ad6 (diff) | |
Fixed #1661 -- Added logic for string-form model references in the 'to' argument of OneToOneFields. Includes regression test.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3197 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/string_lookup/models.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/regressiontests/string_lookup/models.py b/tests/regressiontests/string_lookup/models.py index 7dd31f572d..a4582ca4e9 100644 --- a/tests/regressiontests/string_lookup/models.py +++ b/tests/regressiontests/string_lookup/models.py @@ -21,9 +21,22 @@ class Whiz(models.Model): def __str__(self): return "Whiz %s" % self.name +class Child(models.Model): + parent = models.OneToOneField('Base') + name = models.CharField(maxlength = 50) + + def __str__(self): + return "Child %s" % self.name + +class Base(models.Model): + name = models.CharField(maxlength = 50) + + def __str__(self): + return "Base %s" % self.name + API_TESTS = """ -# Regression test for #1662: Check that string form referencing of models works, both as -# pre and post reference +# Regression test for #1661 and #1662: Check that string form referencing of models works, +# both as pre and post reference, on all RelatedField types. >>> f1 = Foo(name="Foo1") >>> f1.save() @@ -45,4 +58,12 @@ API_TESTS = """ >>> b1.back <Foo: Foo Foo1> +>>> base1 = Base(name="Base1") +>>> base1.save() + +>>> child1 = Child(name="Child1", parent=base1) +>>> child1.save() + +>>> child1.parent +<Base: Base Base1> """ |
