import importlib from django.conf import settings admin_permissions = [] for module in ["core"] + settings.EXPEPHALON_MODULES: try: mop = importlib.import_module(f"{module}.permissions") for admin_permission in mop.ADMIN_PERMISSIONS: admin_permissions.append(admin_permission) except (AttributeError, ModuleNotFoundError): continue admin_permissions = tuple(admin_permissions)