Repository: encode/django-rest-framework

Issue:
Resolve deprecation warnings with Django 1.8
RemovedInDjango19Warning: Loading the `url` tag from the `future` library is deprecated and will be removed in Django 1.9. Use the default `url` tag instead.

base.html
{% load url from future %}



Discussion:
This is blocked by the support of Django < 1.5

Okay, lets plan to resolve this at the same time as we drop support for 1.4.
I have no issue with us bumping up some versions in our next major release.

Agreed.

Not sure if this was addressed already or not:

``` python
/usr/local/lib/python2.7/site-packages/rest_framework/settings.py:23: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
```

> Not sure if this was addressed already or not:

That was addressed in https://github.com/tomchristie/django-rest-framework/pull/2567.

@kevin-brown Thanks!


Resolving patch:
diff --git a/rest_framework/compat.py b/rest_framework/compat.py
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -203,41 +203,6 @@ def __init__(self, *args, **kwargs):
     View.http_method_names = View.http_method_names + ['patch']
 
 
-
-try:
-    # In 1.5 the test client uses force_bytes
-    from django.utils.encoding import force_bytes as force_bytes_or_smart_bytes
-except ImportError:
-    # In 1.4 the test client just uses smart_str
-    from django.utils.encoding import smart_str as force_bytes_or_smart_bytes
-
-
-# RequestFactory only provides `generic` from 1.5 onwards
-if django.VERSION >= (1, 5):
-    from django.test.client import RequestFactory
-else:
-    from django.test.client import RequestFactory as DjangoRequestFactory
-
-    class RequestFactory(DjangoRequestFactory):
-        def generic(self, method, path,
-                data='', content_type='application/octet-stream', **extra):
-            parsed = _urlparse(path)
-            data = force_bytes_or_smart_bytes(data, settings.DEFAULT_CHARSET)
-            r = {
-                'PATH_INFO': self._get_path(parsed),
-                'QUERY_STRING': force_text(parsed[4]),
-                'REQUEST_METHOD': six.text_type(method),
-            }
-            if data:
-                r.update({
-                    'CONTENT_LENGTH': len(data),
-                    'CONTENT_TYPE': six.text_type(content_type),
-                    'wsgi.input': FakePayload(data),
-                })
-            r.update(extra)
-            return self.request(**r)
-
-
 # Markdown is optional
 try:
     import markdown


Test patch:
diff --git a/rest_framework/test.py b/rest_framework/test.py
--- a/rest_framework/test.py
+++ b/rest_framework/test.py
@@ -8,12 +8,12 @@
 from django.conf import settings
 from django.test import testcases
 from django.test.client import Client as DjangoClient
+from django.test.client import RequestFactory as DjangoRequestFactory
 from django.test.client import ClientHandler
 from django.utils import six
+from django.utils.encoding import force_bytes
 from django.utils.http import urlencode
 
-from rest_framework.compat import RequestFactory as DjangoRequestFactory
-from rest_framework.compat import force_bytes_or_smart_bytes
 from rest_framework.settings import api_settings
 
 
@@ -47,7 +47,7 @@ def _encode_data(self, data, format=None, content_type=None):
 
         if content_type:
             # Content type specified explicitly, treat data as a raw bytestring
-            ret = force_bytes_or_smart_bytes(data, settings.DEFAULT_CHARSET)
+            ret = force_bytes(data, settings.DEFAULT_CHARSET)
 
         else:
             format = format or self.default_format