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 -*-
|
2006-06-23 04:37:00 +00:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
def __unicode__(self):
|
2006-06-23 04:37:00 +00:00
|
|
|
return "Foo %s" % self.name
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
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
|
|
|
def __unicode__(self):
|
2006-06-23 04:37:00 +00:00
|
|
|
return "Bar %s" % self.place.name
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
def __unicode__(self):
|
2006-06-23 04:37:00 +00:00
|
|
|
return "Whiz %s" % self.name
|
|
|
|
|
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
|
|
|
|
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
|
|
|
def __unicode__(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
|
|
|
|
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
|
|
|
|
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
|
|
|
def __unicode__(self):
|
2006-06-23 08:16:36 +00:00
|
|
|
return "Base %s" % self.name
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Article %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
|
|
|
__test__ = {'API_TESTS': ur"""
|
|
|
|
# Regression test for #1661 and #1662: Check that string form referencing of
|
|
|
|
# models works, both as pre and post reference, on all RelatedField types.
|
2006-06-23 04:37:00 +00:00
|
|
|
|
|
|
|
>>> f1 = Foo(name="Foo1")
|
|
|
|
>>> f1.save()
|
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
|
|
|
>>> f2 = Foo(name="Foo2")
|
2006-06-23 04:37:00 +00:00
|
|
|
>>> f2.save()
|
|
|
|
|
|
|
|
>>> w1 = Whiz(name="Whiz1")
|
|
|
|
>>> w1.save()
|
|
|
|
|
|
|
|
>>> b1 = Bar(name="Bar1", normal=f1, fwd=w1, back=f2)
|
|
|
|
>>> b1.save()
|
|
|
|
|
|
|
|
>>> b1.normal
|
|
|
|
<Foo: Foo Foo1>
|
|
|
|
|
|
|
|
>>> b1.fwd
|
|
|
|
<Whiz: Whiz Whiz1>
|
|
|
|
|
|
|
|
>>> b1.back
|
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
|
|
|
<Foo: Foo Foo2>
|
2006-06-23 04:37:00 +00:00
|
|
|
|
2006-06-23 08:16:36 +00:00
|
|
|
>>> base1 = Base(name="Base1")
|
|
|
|
>>> base1.save()
|
|
|
|
|
|
|
|
>>> child1 = Child(name="Child1", parent=base1)
|
|
|
|
>>> child1.save()
|
|
|
|
|
|
|
|
>>> child1.parent
|
|
|
|
<Base: Base Base1>
|
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
|
|
|
|
|
|
|
# Regression tests for #3937: make sure we can use unicode characters in
|
|
|
|
# queries.
|
|
|
|
# BUG: These tests fail on MySQL, but it's a problem with the test setup. A
|
|
|
|
# properly configured UTF-8 database can handle this.
|
|
|
|
|
|
|
|
>>> fx = Foo(name='Bjorn', friend=u'François')
|
|
|
|
>>> fx.save()
|
|
|
|
>>> Foo.objects.get(friend__contains=u'\xe7')
|
|
|
|
<Foo: Foo Bjorn>
|
|
|
|
|
|
|
|
# We can also do the above query using UTF-8 strings.
|
|
|
|
>>> Foo.objects.get(friend__contains='\xc3\xa7')
|
|
|
|
<Foo: Foo Bjorn>
|
2007-08-19 12:37:00 +00:00
|
|
|
|
|
|
|
# Regression tests for #5087: make sure we can perform queries on TextFields.
|
|
|
|
>>> a = Article(name='Test', text='The quick brown fox jumps over the lazy dog.')
|
|
|
|
>>> a.save()
|
|
|
|
>>> Article.objects.get(text__exact='The quick brown fox jumps over the lazy dog.')
|
|
|
|
<Article: Article Test>
|
|
|
|
|
|
|
|
>>> Article.objects.get(text__contains='quick brown fox')
|
|
|
|
<Article: Article Test>
|
2006-08-27 13:59:47 +00:00
|
|
|
"""}
|