Skip to content
Snippets Groups Projects
Commit 5d7285b6 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch...

Merge branch '808-apps-should-be-able-to-register-urls-for-api-stuff-which-are-not-mounted-under-django' into 'master'

Resolve "Apps should be able to register URLs for API stuff which are not mounted under /django/"

Closes #808

See merge request AlekSIS/official/AlekSIS-Core!1191
parents d1270c34 9e90db7e
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,12 +412,18 @@ for app_config in apps.app_configs.values(): ...@@ -410,12 +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"))
)
except ModuleNotFoundError: except ModuleNotFoundError:
# Ignore exception as app just has no URLs # Ignore exception as app just has no URLs
pass # noqa urls_module = None
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)))
urlpatterns.append( urlpatterns.append(
re_path( re_path(
......
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