2006-10-14 02:48:05 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
|
2006-10-14 02:48:05 +00:00
|
|
|
class Poll(models.Model):
|
2007-08-05 05:14:46 +00:00
|
|
|
question = models.CharField(max_length=200)
|
2006-10-14 02:48:05 +00:00
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2006-10-14 02:48:05 +00:00
|
|
|
class Choice(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
poll = models.ForeignKey(Poll, models.CASCADE)
|
2007-08-05 05:14:46 +00:00
|
|
|
choice = models.CharField(max_length=200)
|
2006-10-14 02:48:05 +00:00
|
|
|
|
2009-03-06 02:02:09 +00:00
|
|
|
# A set of models with an inner one pointing to two outer ones.
|
2013-11-02 21:34:05 +00:00
|
|
|
|
|
|
|
|
2009-03-06 02:02:09 +00:00
|
|
|
class OuterA(models.Model):
|
|
|
|
pass
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2009-03-06 02:02:09 +00:00
|
|
|
class OuterB(models.Model):
|
|
|
|
data = models.CharField(max_length=10)
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2009-03-06 02:02:09 +00:00
|
|
|
class Inner(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
first = models.ForeignKey(OuterA, models.CASCADE)
|
2013-02-10 15:15:49 +00:00
|
|
|
# second would clash with the __second lookup.
|
2015-07-22 14:43:21 +00:00
|
|
|
third = models.ForeignKey(OuterB, models.SET_NULL, null=True)
|