From f94e7b3207f4c6bd1604a3310acf2bc53780d3e6 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Fri, 12 Jan 2024 18:56:27 +0100 Subject: [PATCH] fix: use proper uri rewrites --- spejstore/urls.py | 12 ++++++------ storage/urls.py | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/spejstore/urls.py b/spejstore/urls.py index 6d68ff2..e898e07 100644 --- a/spejstore/urls.py +++ b/spejstore/urls.py @@ -3,7 +3,7 @@ The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ """ -from django.conf.urls import url, include +from django.urls import re_path, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static @@ -24,16 +24,16 @@ router.register(r"labels", apiviews.LabelViewSet) urlpatterns = ( ( [ - url(r"^admin/login/.*", auth_redirect), + re_path(r"^admin/login/.*", auth_redirect), ] if settings.PROD else [] ) + [ - url(r"^admin/", admin.site.urls), - url(r"^select2/", include("django_select2.urls")), - url(r"^", include("storage.urls")), - url(r"^api/1/", include(router.urls)), + re_path(r"^admin/", admin.site.urls), + re_path(r"^select2/", include("django_select2.urls")), + re_path(r"^", include("storage.urls")), + re_path(r"^api/1/", include(router.urls)), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/storage/urls.py b/storage/urls.py index 9e2eca5..ca27cd6 100644 --- a/storage/urls.py +++ b/storage/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import include, url +from django.urls import re_path, include from storage.views import ( index, search, @@ -10,12 +10,14 @@ from storage.views import ( ) urlpatterns = [ - url(r"^$", index), - url(r"^search$", search), - url(r"^apitoken$", apitoken), - url(r"^item/(?P.*)$", item_display, name="item-display"), - url(r"^autocomplete.json$", ItemSelectView.as_view(), name="item-complete"), - url(r"^autocomplete_prop.json$", PropSelectView.as_view(), name="prop-complete"), - url(r"^(?P[^/]*)$", label_lookup, name="label-lookup"), - url("", include("social_django.urls", namespace="social")), + re_path(r"^$", index), + re_path(r"^search$", search), + re_path(r"^apitoken$", apitoken), + re_path(r"^item/(?P.*)$", item_display, name="item-display"), + re_path(r"^autocomplete.json$", ItemSelectView.as_view(), name="item-complete"), + re_path( + r"^autocomplete_prop.json$", PropSelectView.as_view(), name="prop-complete" + ), + re_path(r"^(?P[^/]*)$", label_lookup, name="label-lookup"), + re_path("", include("social_django.urls", namespace="social")), ]