mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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
This commit is contained in:
@@ -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>
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user