From 88a9a99cfcb3b6d78329884ccb4bdf94325647d7 Mon Sep 17 00:00:00 2001 From: Jair Henrique Date: Thu, 14 May 2020 09:18:35 -0300 Subject: [PATCH] Remove compat urls for Django < 2.0 --- rest_framework/compat.py | 10 ---------- rest_framework/urlpatterns.py | 3 ++- tests/schemas/test_coreapi.py | 3 ++- tests/test_urlpatterns.py | 4 ++-- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 1de23bfaa..acace3467 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -212,16 +212,6 @@ else: return False -# Django 1.x url routing syntax. Remove when dropping Django 1.11 support. -try: - from django.urls import include, path, re_path, register_converter # noqa -except ImportError: - from django.conf.urls import include, url # noqa - path = None - register_converter = None - re_path = url - - # `separators` argument to `json.dumps()` differs between 2.x and 3.x # See: https://bugs.python.org/issue22767 SHORT_SEPARATORS = (',', ':') diff --git a/rest_framework/urlpatterns.py b/rest_framework/urlpatterns.py index 831d344dd..9c82e1633 100644 --- a/rest_framework/urlpatterns.py +++ b/rest_framework/urlpatterns.py @@ -1,7 +1,8 @@ from django.conf.urls import include, url +from django.urls import path, register_converter from rest_framework.compat import ( - URLResolver, get_regex_pattern, is_route_pattern, path, register_converter + URLResolver, get_regex_pattern, is_route_pattern ) from rest_framework.settings import api_settings diff --git a/tests/schemas/test_coreapi.py b/tests/schemas/test_coreapi.py index a634d6968..77e18a9a1 100644 --- a/tests/schemas/test_coreapi.py +++ b/tests/schemas/test_coreapi.py @@ -5,11 +5,12 @@ from django.conf.urls import include, url from django.core.exceptions import PermissionDenied from django.http import Http404 from django.test import TestCase, override_settings +from django.urls import path from rest_framework import ( filters, generics, pagination, permissions, serializers ) -from rest_framework.compat import coreapi, coreschema, get_regex_pattern, path +from rest_framework.compat import coreapi, coreschema, get_regex_pattern from rest_framework.decorators import action, api_view, schema from rest_framework.request import Request from rest_framework.routers import DefaultRouter, SimpleRouter diff --git a/tests/test_urlpatterns.py b/tests/test_urlpatterns.py index 25cc0032e..51d269535 100644 --- a/tests/test_urlpatterns.py +++ b/tests/test_urlpatterns.py @@ -3,9 +3,9 @@ from collections import namedtuple from django.conf.urls import include, url from django.test import TestCase -from django.urls import Resolver404 +from django.urls import Resolver404, path, re_path -from rest_framework.compat import make_url_resolver, path, re_path +from rest_framework.compat import make_url_resolver from rest_framework.test import APIRequestFactory from rest_framework.urlpatterns import format_suffix_patterns