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 20:11:04 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-08-12 04:20:59 +08:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2006-06-23 12:37:00 +08:00
|
|
|
from django.db import models
|
2012-08-12 18:32:08 +08:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2006-06-23 12:37:00 +08:00
|
|
|
|
2011-10-14 05:34:56 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
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
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2006-06-23 12:37:00 +08:00
|
|
|
return "Foo %s" % self.name
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
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
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2006-06-23 12:37:00 +08:00
|
|
|
return "Bar %s" % self.place.name
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
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
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2006-06-23 12:37:00 +08:00
|
|
|
return "Whiz %s" % self.name
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
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
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2006-06-23 16:16:36 +08: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 20:11:04 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
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
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2006-06-23 16:16:36 +08:00
|
|
|
return "Base %s" % self.name
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
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)
|
2007-08-19 20:37:00 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2007-08-19 20:37:00 +08:00
|
|
|
return "Article %s" % self.name
|