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