Fixed #23455 -- Accept either bytes or text for related_name, convert to text.

This commit is contained in:
Carl Meyer 2014-12-11 17:28:03 -07:00
parent d4bdddeefe
commit c72eb80d11
4 changed files with 10 additions and 6 deletions

View file

@ -25,7 +25,7 @@ def get_foo():
class Bar(models.Model):
b = models.CharField(max_length=10)
a = models.ForeignKey(Foo, default=get_foo)
a = models.ForeignKey(Foo, default=get_foo, related_name=b'bars')
class Whiz(models.Model):

View file

@ -199,6 +199,10 @@ class ForeignKeyTests(test.TestCase):
warnings = checks.run_checks()
self.assertEqual(warnings, expected_warnings)
def test_related_name_converted_to_text(self):
rel_name = Bar._meta.get_field_by_name('a')[0].rel.related_name
self.assertIsInstance(rel_name, six.text_type)
class DateTimeFieldTests(unittest.TestCase):
def test_datetimefield_to_python_usecs(self):