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
|
|
|
# -*- coding: utf-8 -*-
|
2012-08-11 20:20:59 +00:00
|
|
|
from __future__ import unicode_literals
|
2013-09-28 08:22:46 +00:00
|
|
|
import warnings
|
2012-08-11 20:20:59 +00:00
|
|
|
|
2006-06-23 04:37:00 +00:00
|
|
|
from django.db import models
|
2012-08-12 10:32:08 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2006-06-23 04:37:00 +00:00
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
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)
|
2006-06-23 04:37:00 +00:00
|
|
|
normal = models.ForeignKey(Foo, related_name='normal_foo')
|
|
|
|
fwd = models.ForeignKey("Whiz")
|
|
|
|
back = models.ForeignKey("Foo")
|
|
|
|
|
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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2006-06-23 08:16:36 +00:00
|
|
|
class Child(models.Model):
|
|
|
|
parent = models.OneToOneField('Base')
|
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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
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
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
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()
|
2013-09-28 08:22:46 +00:00
|
|
|
with warnings.catch_warnings(record=True) as w:
|
|
|
|
warnings.simplefilter("always")
|
|
|
|
submitted_from = models.IPAddressField(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
|