From 4206f55b36c06124025c56799606ac39e6a28827 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Sat, 19 Dec 2020 20:17:57 +0100 Subject: [PATCH] Just define own urls.py so we also support settings.SERVE_FILES here, too. And this removes one warnings about duplicate namespaces. --- conf/ynh_urls.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/conf/ynh_urls.py b/conf/ynh_urls.py index 57a7f7c..eef81a2 100644 --- a/conf/ynh_urls.py +++ b/conf/ynh_urls.py @@ -1,16 +1,25 @@ from django.conf import settings -from django.conf.urls import include +from django.conf.urls import include, static +from django.contrib import admin from django.urls import path +from django.views.generic import RedirectView # settings.PATH_URL is the $YNH_APP_ARG_PATH if settings.PATH_URL: + # Prefix all urls with "PATH_URL": urlpatterns = [ - # XXX: Hack - the MEDIA_URL contains the "PATH_URL" already: - path(settings.MEDIA_URL.lstrip('/'), include('django_tools.serve_media_app.urls')), + path(f'{settings.PATH_URL}/admin/', admin.site.urls), - # Prefix all urls with "PATH_URL": - path(f'{settings.PATH_URL}/', include('inventory_project.urls')) + path(f'{settings.PATH_URL}/', RedirectView.as_view(pattern_name='admin:index')), + + path(f'{settings.PATH_URL}/ckeditor/', include('ckeditor_uploader.urls')), + + # MEDIA_URL contains the "PATH_URL" already: + path(settings.MEDIA_URL.lstrip('/'), include('django_tools.serve_media_app.urls')), ] + if settings.SERVE_FILES: + urlpatterns += static.static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) else: - # Installed to domain root, without a path prefix? + # Installed to domain root, without a path prefix + # Just use the default project urls.py from inventory_project.urls import urlpatterns # noqa