Skip to content
Snippets Groups Projects
Verified Commit f92ce074 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Mount API URLs directly under app namespace and not under /django/

parent 039b944a
No related branches found
No related tags found
1 merge request!1191Resolve "Apps should be able to register URLs for API stuff which are not mounted under /django/"
Pipeline #116448 failed
from importlib import import_module
from django.apps import apps
from django.conf import settings
from django.contrib import admin
......@@ -410,10 +412,18 @@ for app_config in apps.app_configs.values():
continue
try:
urlpatterns.append(
path(f"django/app/{app_config.label}/", include(f"{app_config.name}.urls"))
)
except ModuleNotFoundError:
urls_module = import_module(f"{app_config.name}.urls")
if hasattr(urls_module, "urlpatterns"):
urlpatterns.append(
path(f"django/app/{app_config.label}/", include(urls_module.urlpatterns))
)
if hasattr(urls_module, "api_urlpatterns"):
urlpatterns.append(
path(f"app/{app_config.label}/", include(urls_module.api_urlpatterns))
)
except ImportError:
# Ignore exception as app just has no URLs
pass # noqa
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment