autodiscovery Β€
Functions:
-
autodiscoverβSearch for all python files in
-
import_librariesβImport modules set in
autodiscover Β€
Search for all python files in COMPONENTS.dirs and COMPONENTS.app_dirs and import them.
See Autodiscovery.
Parameters:
-
map_module(Callable[[str], str], default:None) βMap the module paths with
map_modulefunction. This serves as an escape hatch for when you need to use this function in tests.
Returns:
To get the same list of modules that autodiscover() would return, but without importing them, use get_component_files():
Source code in src/django_components/autodiscovery.py
import_libraries Β€
Import modules set in COMPONENTS.libraries setting.
See Autodiscovery.
Parameters:
-
map_module(Callable[[str], str], default:None) βMap the module paths with
map_modulefunction. This serves as an escape hatch for when you need to use this function in tests.
Returns:
Examples:
Normal usage - load libraries after Django has loaded
from django_components import import_libraries
class MyAppConfig(AppConfig):
def ready(self):
import_libraries()
Potential usage in tests
from django_components import import_libraries
import_libraries(lambda path: path.replace("tests.", "myapp."))