diff options
| author | Justin Bronn <jbronn@gmail.com> | 2008-02-28 21:24:51 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2008-02-28 21:24:51 +0000 |
| commit | 22e016ff6c18a35a450519b94de63033f83e6b4f (patch) | |
| tree | 1e58cc40a636b4e4f3dcf429a5a116c015c36278 /tests/modeltests/mutually_referential/models.py | |
| parent | 0b52413cc926446f238fd781b4def6804f64d231 (diff) | |
gis: Merged revisions 7105-7168 via svnmerge from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7176 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/mutually_referential/models.py')
| -rw-r--r-- | tests/modeltests/mutually_referential/models.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/modeltests/mutually_referential/models.py b/tests/modeltests/mutually_referential/models.py index 7cf7bf8bb2..5176721f3d 100644 --- a/tests/modeltests/mutually_referential/models.py +++ b/tests/modeltests/mutually_referential/models.py @@ -1,18 +1,22 @@ """ 24. Mutually referential many-to-one relationships -To define a many-to-one relationship, use ``ForeignKey()`` . +Strings can be used instead of model literals to set up "lazy" relations. """ from django.db.models import * class Parent(Model): name = CharField(max_length=100, core=True) + + # Use a simple string for forward declarations. bestchild = ForeignKey("Child", null=True, related_name="favoured_by") class Child(Model): name = CharField(max_length=100) - parent = ForeignKey(Parent) + + # You can also explicitally specify the related app. + parent = ForeignKey("mutually_referential.Parent") __test__ = {'API_TESTS':""" # Create a Parent |
