From 92cad0d2fa918b835b5bdd13ee29c61a58c68329 Mon Sep 17 00:00:00 2001 From: VladSaichenko Date: Sat, 22 Aug 2020 02:28:13 +0700 Subject: [PATCH] url() replaced on re_path() in routers.py --- rest_framework/routers.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 657ad67bc..e2afa573f 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -16,9 +16,8 @@ For example, you might have a `urls.py` that looks something like this: import itertools from collections import OrderedDict, namedtuple -from django.conf.urls import url from django.core.exceptions import ImproperlyConfigured -from django.urls import NoReverseMatch +from django.urls import NoReverseMatch, re_path from rest_framework import views from rest_framework.response import Response @@ -265,7 +264,7 @@ class SimpleRouter(BaseRouter): view = viewset.as_view(mapping, **initkwargs) name = route.name.format(basename=basename) - ret.append(url(regex, view, name=name)) + ret.append(re_path(regex, view, name=name)) return ret @@ -340,7 +339,7 @@ class DefaultRouter(SimpleRouter): if self.include_root_view: view = self.get_api_root_view(api_urls=urls) - root_url = url(r'^$', view, name=self.root_view_name) + root_url = re_path(r'^$', view, name=self.root_view_name) urls.append(root_url) if self.include_format_suffixes: