Skip to content

Commit 74fec7e

Browse files
author
Ian Foote
committed
Import force_bytes on django >= 1.5
1 parent 0383f11 commit 74fec7e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

rest_framework/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def smart_urlquote(url):
457457
from django.test.client import FakePayload
458458
try:
459459
# In 1.5 the test client uses force_bytes
460-
from django.utils.encoding import force_bytes_or_smart_bytes
460+
from django.utils.encoding import force_bytes as force_bytes_or_smart_bytes
461461
except ImportError:
462462
# In 1.3 and 1.4 the test client just uses smart_str
463463
from django.utils.encoding import smart_str as force_bytes_or_smart_bytes
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import django
2+
from django.test import TestCase
3+
4+
5+
class TestCompat(TestCase):
6+
def test_force_bytes_or_smart_bytes(self):
7+
from rest_framework.compat import force_bytes_or_smart_bytes
8+
if django.VERSION >= (1, 5):
9+
from django.utils.encoding import force_bytes
10+
self.assertEqual(force_bytes_or_smart_bytes, force_bytes)
11+
else:
12+
from django.utils.encoding import smart_str
13+
self.assertEqual(force_bytes_or_smart_bytes, smart_str)

0 commit comments

Comments
 (0)