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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2006-06-23 04:37:00 +00:00
|
|
|
return "Foo %s" % self.name
|
|
|
|
|
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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2006-06-23 04:37:00 +00:00
|
|
|
return "Bar %s" % self.place.name
|
|
|
|
|
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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2006-06-23 04:37:00 +00:00
|
|
|
return "Whiz %s" % self.name
|
|
|
|
|
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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2006-06-23 08:16:36 +00:00
|
|
|
return "Child %s" % self.name
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 12:11:04 +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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2006-06-23 08:16:36 +00:00
|
|
|
return "Base %s" % self.name
|
|
|
|
|
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)
|
2007-08-19 12:37:00 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2007-08-19 12:37:00 +00:00
|
|
|
return "Article %s" % self.name
|