PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/modeltests/mutually_referential/models.py

https://code.google.com/p/mango-py/
Python | 19 lines | 16 code | 0 blank | 3 comment | 0 complexity | b3aae5f0222b1f9637cfaf79a1af438f MD5 | raw file
 1"""
 224. Mutually referential many-to-one relationships
 3
 4Strings can be used instead of model literals to set up "lazy" relations.
 5"""
 6
 7from django.db.models import *
 8
 9class Parent(Model):
10    name = CharField(max_length=100)
11
12    # Use a simple string for forward declarations.
13    bestchild = ForeignKey("Child", null=True, related_name="favoured_by")
14
15class Child(Model):
16    name = CharField(max_length=100)
17
18    # You can also explicitally specify the related app.
19    parent = ForeignKey("mutually_referential.Parent")