2006-06-23 12:37:00 +08:00
|
|
|
from django.db import models
|
|
|
|
|
2011-10-14 05:34:56 +08:00
|
|
|
|
2006-06-23 12:37:00 +08:00
|
|
|
class Foo(models.Model):
|
2007-08-05 13:14:46 +08:00
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
friend = models.CharField(max_length=50, blank=True)
|
2006-06-23 12:37:00 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2006-06-23 12:37:00 +08:00
|
|
|
class Bar(models.Model):
|
2007-08-05 13:14:46 +08:00
|
|
|
name = models.CharField(max_length=50)
|
2015-07-22 22:43:21 +08:00
|
|
|
normal = models.ForeignKey(Foo, models.CASCADE, related_name="normal_foo")
|
|
|
|
fwd = models.ForeignKey("Whiz", models.CASCADE)
|
|
|
|
back = models.ForeignKey("Foo", models.CASCADE)
|
2006-06-23 12:37:00 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2006-06-23 12:37:00 +08:00
|
|
|
class Whiz(models.Model):
|
2007-12-02 09:45:59 +08:00
|
|
|
name = models.CharField(max_length=50)
|
2006-06-23 12:37:00 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2006-06-23 16:16:36 +08:00
|
|
|
class Child(models.Model):
|
2015-07-22 22:43:21 +08:00
|
|
|
parent = models.OneToOneField("Base", models.CASCADE)
|
2007-12-02 09:45:59 +08:00
|
|
|
name = models.CharField(max_length=50)
|
2006-06-23 16:16:36 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2006-06-23 16:16:36 +08:00
|
|
|
class Base(models.Model):
|
2007-12-02 09:45:59 +08:00
|
|
|
name = models.CharField(max_length=50)
|
2006-06-23 16:16:36 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2007-08-19 20:37:00 +08:00
|
|
|
class Article(models.Model):
|
2007-12-02 09:45:59 +08:00
|
|
|
name = models.CharField(max_length=50)
|
2007-08-19 20:37:00 +08:00
|
|
|
text = models.TextField()
|
2014-12-22 04:19:05 +08:00
|
|
|
submitted_from = models.GenericIPAddressField(blank=True, null=True)
|