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
No related merge requests found
from importlib import import_module
from django.apps import apps from django.apps import apps
from django.conf import settings from django.conf import settings
from django.contrib import admin from django.contrib import admin
...@@ -410,10 +412,18 @@ for app_config in apps.app_configs.values(): ...@@ -410,10 +412,18 @@ for app_config in apps.app_configs.values():
continue continue
try: try:
urlpatterns.append( urls_module = import_module(f"{app_config.name}.urls")
path(f"django/app/{app_config.label}/", include(f"{app_config.name}.urls"))
) if hasattr(urls_module, "urlpatterns"):
except ModuleNotFoundError: 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 # Ignore exception as app just has no URLs
pass # noqa 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