init
This commit is contained in:
19
app/api/autoload.py
Normal file
19
app/api/autoload.py
Normal 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}")
|
||||
Reference in New Issue
Block a user