This commit is contained in:
2025-08-31 00:29:53 +02:00
parent 191bd84573
commit 29611b15ca
87 changed files with 2451 additions and 0 deletions

19
app/api/autoload.py Normal file
View File

@@ -0,0 +1,19 @@
from django.conf import settings
import importlib
def load_viewset_registries(router):
"""
Parcourt toutes les apps installées et appelle leur register_viewsets(router) si présent.
"""
for app in settings.INSTALLED_APPS:
module_path = f"{app}.api.registry"
try:
module = importlib.import_module(module_path)
if hasattr(module, "register_viewsets"):
module.register_viewsets(router)
except ModuleNotFoundError:
continue
except AttributeError as e:
print(f"[ERROR] Could not import {module_path}: {e}")