From 2bd1845372e6eb8d9744b89d7599b622ee6c802e Mon Sep 17 00:00:00 2001 From: sanjusci Date: Sun, 19 Jul 2020 09:39:03 +0530 Subject: [PATCH] update given feedbacks on url() is deprecated in Django 3.1 --- docs/api-guide/format-suffixes.md | 2 +- docs/api-guide/generic-views.md | 2 +- docs/tutorial/4-authentication-and-permissions.md | 2 +- rest_framework/documentation.py | 3 +-- rest_framework/urlpatterns.py | 3 +-- tests/authentication/test_authentication.py | 3 +-- tests/browsable_api/auth_urls.py | 3 +-- tests/schemas/test_coreapi.py | 3 +-- tests/test_renderers.py | 3 +-- tests/test_response.py | 3 +-- tests/test_routers.py | 3 +-- tests/test_urlpatterns.py | 3 +-- tests/test_versioning.py | 3 +-- tests/test_viewsets.py | 3 +-- 14 files changed, 14 insertions(+), 25 deletions(-) diff --git a/docs/api-guide/format-suffixes.md b/docs/api-guide/format-suffixes.md index 0aa75dbef..dfdf24953 100644 --- a/docs/api-guide/format-suffixes.md +++ b/docs/api-guide/format-suffixes.md @@ -32,7 +32,7 @@ Example: from blog import views urlpatterns = [ - path('/', views.apt_root), + path('', views.apt_root), path('comments/', views.comment_list), path('comments//', views.comment_detail) ] diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 26344536b..afc2cab56 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -45,7 +45,7 @@ For more complex cases you might also want to override various methods on the vi For very simple cases you might want to pass through any class attributes using the `.as_view()` method. For example, your URLconf might include something like the following entry: - path('/users/', ListCreateAPIView.as_view(queryset=User.objects.all(), serializer_class=UserSerializer), name='user-list') + path('users/', ListCreateAPIView.as_view(queryset=User.objects.all(), serializer_class=UserSerializer), name='user-list') --- diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md index 6808780fa..79ce355c9 100644 --- a/docs/tutorial/4-authentication-and-permissions.md +++ b/docs/tutorial/4-authentication-and-permissions.md @@ -137,7 +137,7 @@ We can add a login view for use with the browsable API, by editing the URLconf i Add the following import at the top of the file: - from django.conf.urls import include + from django.urls import path, include And, at the end of the file, add a pattern to include the login and logout views for the browsable API. diff --git a/rest_framework/documentation.py b/rest_framework/documentation.py index b6fa2e07f..53e5ab551 100644 --- a/rest_framework/documentation.py +++ b/rest_framework/documentation.py @@ -1,5 +1,4 @@ -from django.conf.urls import include -from django.urls import path +from django.urls import include, path from rest_framework.renderers import ( CoreJSONRenderer, DocumentationRenderer, SchemaJSRenderer diff --git a/rest_framework/urlpatterns.py b/rest_framework/urlpatterns.py index ed8f14f89..c189465fb 100644 --- a/rest_framework/urlpatterns.py +++ b/rest_framework/urlpatterns.py @@ -1,5 +1,4 @@ -from django.conf.urls import include -from django.urls import URLResolver, path, re_path, register_converter +from django.urls import URLResolver, include, path, re_path, register_converter from django.urls.resolvers import RoutePattern from rest_framework.settings import api_settings diff --git a/tests/authentication/test_authentication.py b/tests/authentication/test_authentication.py index 689ea1565..e2ab3654e 100644 --- a/tests/authentication/test_authentication.py +++ b/tests/authentication/test_authentication.py @@ -2,11 +2,10 @@ import base64 import pytest from django.conf import settings -from django.conf.urls import include from django.contrib.auth.models import User from django.http import HttpResponse from django.test import TestCase, override_settings -from django.urls import path +from django.urls import include, path from rest_framework import ( HTTP_HEADER_ENCODING, exceptions, permissions, renderers, status diff --git a/tests/browsable_api/auth_urls.py b/tests/browsable_api/auth_urls.py index 28f168666..151278cbd 100644 --- a/tests/browsable_api/auth_urls.py +++ b/tests/browsable_api/auth_urls.py @@ -1,5 +1,4 @@ -from django.conf.urls import include -from django.urls import path +from django.urls import include, path from .views import MockView diff --git a/tests/schemas/test_coreapi.py b/tests/schemas/test_coreapi.py index 0492345eb..f6937b06f 100644 --- a/tests/schemas/test_coreapi.py +++ b/tests/schemas/test_coreapi.py @@ -1,11 +1,10 @@ import unittest import pytest -from django.conf.urls import include from django.core.exceptions import PermissionDenied from django.http import Http404 from django.test import TestCase, override_settings -from django.urls import path +from django.urls import include, path from rest_framework import ( filters, generics, pagination, permissions, serializers diff --git a/tests/test_renderers.py b/tests/test_renderers.py index fddd5e2dd..8271608e1 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -3,13 +3,12 @@ from collections import OrderedDict from collections.abc import MutableMapping import pytest -from django.conf.urls import include from django.core.cache import cache from django.db import models from django.http.request import HttpRequest from django.template import loader from django.test import TestCase, override_settings -from django.urls import path, re_path +from django.urls import include, path, re_path from django.utils.safestring import SafeText from django.utils.translation import gettext_lazy as _ diff --git a/tests/test_response.py b/tests/test_response.py index c52a1b21d..0d5528dc9 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -1,6 +1,5 @@ -from django.conf.urls import include from django.test import TestCase, override_settings -from django.urls import path, re_path +from django.urls import include, path, re_path from rest_framework import generics, routers, serializers, status, viewsets from rest_framework.parsers import JSONParser diff --git a/tests/test_routers.py b/tests/test_routers.py index ba5cdc4c2..f767a843d 100644 --- a/tests/test_routers.py +++ b/tests/test_routers.py @@ -1,11 +1,10 @@ from collections import namedtuple import pytest -from django.conf.urls import include from django.core.exceptions import ImproperlyConfigured from django.db import models from django.test import TestCase, override_settings -from django.urls import path, resolve, reverse +from django.urls import include, path, resolve, reverse from rest_framework import permissions, serializers, viewsets from rest_framework.decorators import action diff --git a/tests/test_urlpatterns.py b/tests/test_urlpatterns.py index 7b833ca2e..d860ea34b 100644 --- a/tests/test_urlpatterns.py +++ b/tests/test_urlpatterns.py @@ -1,9 +1,8 @@ import unittest from collections import namedtuple -from django.conf.urls import include from django.test import TestCase -from django.urls import Resolver404, URLResolver, path, re_path +from django.urls import Resolver404, URLResolver, include, path, re_path from django.urls.resolvers import RegexPattern from rest_framework.test import APIRequestFactory diff --git a/tests/test_versioning.py b/tests/test_versioning.py index 99a3a592b..d40d54229 100644 --- a/tests/test_versioning.py +++ b/tests/test_versioning.py @@ -1,7 +1,6 @@ import pytest -from django.conf.urls import include from django.test import override_settings -from django.urls import path, re_path +from django.urls import include, path, re_path from rest_framework import serializers, status, versioning from rest_framework.decorators import APIView diff --git a/tests/test_viewsets.py b/tests/test_viewsets.py index 5d0a1005c..68fbc25f6 100644 --- a/tests/test_viewsets.py +++ b/tests/test_viewsets.py @@ -1,10 +1,9 @@ from collections import OrderedDict import pytest -from django.conf.urls import include from django.db import models from django.test import TestCase, override_settings -from django.urls import path +from django.urls import include, path from rest_framework import status from rest_framework.decorators import action