From 51e917247942aa723e706db8ff6573307410c764 Mon Sep 17 00:00:00 2001 From: Darren Date: Sun, 29 May 2022 13:56:56 -0400 Subject: [PATCH] Revert "Revert "add the posibility of specifying a url prefix"" (#206) * Revert "Revert "add the posibility of specifying a url prefix (#143)" (#205)" * mysql client --- dpaste/settings/base.py | 2 ++ dpaste/urls/__init__.py | 9 ++++++--- setup.cfg | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dpaste/settings/base.py b/dpaste/settings/base.py index 63db06f..3b61056 100644 --- a/dpaste/settings/base.py +++ b/dpaste/settings/base.py @@ -51,6 +51,8 @@ MEDIA_ROOT = env("MEDIA_ROOT", ".media") STATIC_URL = "/static/" +URL_PREFIX = env("URL_PREFIX", "") + ROOT_URLCONF = "dpaste.urls" WSGI_APPLICATION = "dpaste.wsgi.application" diff --git a/dpaste/urls/__init__.py b/dpaste/urls/__init__.py index ad746cf..13b925c 100644 --- a/dpaste/urls/__init__.py +++ b/dpaste/urls/__init__.py @@ -1,9 +1,12 @@ from django.urls import include, re_path +from django.conf import settings + +url_prefix = getattr(settings, "URL_PREFIX", "") urlpatterns = [ - re_path(r"^", include("dpaste.urls.dpaste_api")), - re_path(r"^", include("dpaste.urls.dpaste")), - re_path(r"^i18n/", include("django.conf.urls.i18n")), + re_path(r"^%s" % url_prefix, include("dpaste.urls.dpaste_api")), + re_path(r"^%s" % url_prefix, include("dpaste.urls.dpaste")), + re_path(r"^%si18n/" % url_prefix, include("django.conf.urls.i18n")), ] # Custom error handlers which load `dpaste/.html` instead of `.html` diff --git a/setup.cfg b/setup.cfg index 5ca41fe..d0efa16 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,6 +31,7 @@ install_requires = # Essential packages django>=3.2 pygments>=2.11 + mysqlclient>=2.1.0 django-staticinline>=1.0 django-csp>=3.6 dj_database_url>=0.5.0