Ticket #16299: support-for-unicode-literals.2.diff

File support-for-unicode-literals.2.diff, 1.5 KB (added by martijn.bastiaan@…, 13 years ago)

Patch (2)

  • django/db/models/options.py

    > This patch corrects the assumption that string-references in a model-field
    > are strings. In other words: this patch allows unicode-references.
    >
    > For example,
    > 
    > insert_user = models.ForeignKey(u"models.User", db_column='insertuser_id')
    > *or*
    > from __future__ import unicode_literals
    >
    > would have raised an error. 
    
     
    385385                    cache[obj] = model
    386386        for klass in get_models(include_auto_created=True, only_installed=False):
    387387            for f in klass._meta.local_fields:
    388                 if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta:
     388                if f.rel and not isinstance(f.rel.to, basestring) and self == f.rel.to._meta:
    389389                    cache[RelatedObject(f.rel.to, klass, f)] = None
    390390        self._related_objects_cache = cache
    391391
     
    422422                    cache[obj] = model
    423423        for klass in get_models(only_installed=False):
    424424            for f in klass._meta.local_many_to_many:
    425                 if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta:
     425                if f.rel and not isinstance(f.rel.to, basestring) and self == f.rel.to._meta:
    426426                    cache[RelatedObject(f.rel.to, klass, f)] = None
    427427        if app_cache_ready():
    428428            self._related_many_to_many_cache = cache
Back to Top