1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.7.x] Fixed #23455 -- Accept either bytes or text for related_name, convert to text.

Backport of c72eb80d11 from master.
This commit is contained in:
Carl Meyer
2014-12-11 17:28:03 -07:00
parent b376071936
commit 0a8b911582
4 changed files with 10 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ from django.db.models.lookups import IsNull
from django.db.models.related import RelatedObject, PathInfo
from django.db.models.query import QuerySet
from django.db.models.sql.datastructures import Col
from django.utils.encoding import smart_text
from django.utils.encoding import force_text, smart_text
from django.utils import six
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.translation import ugettext_lazy as _
@@ -259,7 +259,7 @@ class RelatedField(Field):
sup.contribute_to_class(cls, name, virtual_only=virtual_only)
if not cls._meta.abstract and self.rel.related_name:
related_name = self.rel.related_name % {
related_name = force_text(self.rel.related_name) % {
'class': cls.__name__.lower(),
'app_label': cls._meta.app_label.lower()
}