Commit ec1226b8 authored by Malcolm Tredinnick's avatar Malcolm Tredinnick
Browse files

Added another test to confirm fix in r16663.

This is the test case from #6045, which was fixed by the above commit.
Refs #6045, #16299

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16679 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 75ddbf77
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -19,3 +19,7 @@ class Issue(models.Model):

    class Meta:
        ordering = ('num',)

class UnicodeReferenceModel(models.Model): 
    others = models.ManyToManyField(u"UnicodeReferenceModel") 
+14 −1
Original line number Diff line number Diff line
from django.db.models import Q
from django.test import TestCase

from models import Issue, User
from models import Issue, User, UnicodeReferenceModel


class RelatedObjectTests(TestCase):
@@ -73,3 +73,16 @@ class RelatedObjectTests(TestCase):
            ],
            lambda i: i.num
        )

class RelatedObjectTests(TestCase): 
    def test_m2m_with_unicode_reference(self): 
        """
        Regression test for #6045: references to other models can be unicode
        strings, providing they are directly convertible to ASCII.
        """
        m1=UnicodeReferenceModel.objects.create() 
        m2=UnicodeReferenceModel.objects.create() 
        m2.others.add(m1) # used to cause an error (see ticket #6045) 
        m2.save() 
        list(m2.others.all()) # Force retrieval.