summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2014-12-11 17:28:03 -0700
committerCarl Meyer <carl@oddbird.net>2014-12-12 12:50:39 -0700
commitc72eb80d114fb5d90bd21b5549e8abd0bbd17f99 (patch)
treedb8a57ea159e0e00d9edee634ecf7de5f26cdd9c /tests/model_fields
parentd4bdddeefe35214f194cb85e40dbb761c206e7fa (diff)
Fixed #23455 -- Accept either bytes or text for related_name, convert to text.
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/models.py2
-rw-r--r--tests/model_fields/tests.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py
index ed1cfa8e8d..bb75208905 100644
--- a/tests/model_fields/models.py
+++ b/tests/model_fields/models.py
@@ -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):
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index db04b7fcad..ddbf69419c 100644
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -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):