From 9067de088d3ff1ba114e6d4dc931c0847046d92c Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen <andretol@usit.uio.no> Date: Tue, 27 Jul 2021 12:36:10 +0200 Subject: [PATCH] greg.api.urls: fix url deprecation warnings django.conf.urls.url has been deprecated in favour of django.urls.re_path, which has matching behaviour. This silences two warnings during the test run. Fixes: GREG-14 --- greg/api/urls.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/greg/api/urls.py b/greg/api/urls.py index 62ee2d49..caa958da 100644 --- a/greg/api/urls.py +++ b/greg/api/urls.py @@ -1,12 +1,21 @@ -from django.conf.urls import url -from django.urls import path +from django.urls import ( + path, + re_path, +) from rest_framework.routers import DefaultRouter -from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView +from drf_spectacular.views import ( + SpectacularAPIView, + SpectacularSwaggerView, +) -from greg.api.views.person import PersonViewSet, PersonRoleViewSet +from greg.api.views.person import ( + PersonRoleViewSet, + PersonViewSet, +) from greg.api.views.role import RoleViewSet from greg.api.views.health import Health + router = DefaultRouter() router.register(r"persons", PersonViewSet, basename="person") router.register(r"roles", RoleViewSet, basename="role") @@ -21,12 +30,12 @@ urlpatterns += [ name="swagger-ui", ), path("health/", Health.as_view()), - url( + re_path( r"^persons/(?P<person_id>[0-9]+)/roles/$", PersonRoleViewSet.as_view({"get": "list"}), name="person_role-list", ), - url( + re_path( r"^persons/(?P<person_id>[0-9]+)/roles/(?P<id>[0-9]+)/$", PersonRoleViewSet.as_view({"get": "retrieve"}), name="person_role-detail", -- GitLab