mirror of
https://github.com/django/django.git
synced 2025-10-25 22:56:12 +00:00
Fixed #16299 -- Ensure that unicode strings can be used to identify classes in ForeignKey and ManyToManyFields. Unicode strings aren't actually legal as class names, but this is an issue if you use from __future__ import unicode_literals in your models.py file. Thanks to Martijn Bastiaan for the report, and Anthony Briggs for the final patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16663 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -385,7 +385,7 @@ class Options(object):
|
||||
cache[obj] = model
|
||||
for klass in get_models(include_auto_created=True, only_installed=False):
|
||||
for f in klass._meta.local_fields:
|
||||
if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta:
|
||||
if f.rel and not isinstance(f.rel.to, basestring) and self == f.rel.to._meta:
|
||||
cache[RelatedObject(f.rel.to, klass, f)] = None
|
||||
self._related_objects_cache = cache
|
||||
|
||||
@@ -422,7 +422,7 @@ class Options(object):
|
||||
cache[obj] = model
|
||||
for klass in get_models(only_installed=False):
|
||||
for f in klass._meta.local_many_to_many:
|
||||
if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta:
|
||||
if f.rel and not isinstance(f.rel.to, basestring) and self == f.rel.to._meta:
|
||||
cache[RelatedObject(f.rel.to, klass, f)] = None
|
||||
if app_cache_ready():
|
||||
self._related_many_to_many_cache = cache
|
||||
|
||||
Reference in New Issue
Block a user