Auto import a module from all yours apps!
# my.project.settings.py
INSTALLED_APPS = [
...,
'cocodev.django.auto_import',
...,
]
AUTO_IMPORT = 'startup' # Automatically imports `startup.py` in all apps
This is a pretty simple library so there is not much more to it.
Through an allow listing:
# my.project.settings.py
AUTO_IMPORT = 'startup' # Automatically imports `startup.py` in all apps
AUTO_IMPORT_ALLOW_LIST = [
'my.project.app.name', # Will only import `my.project.app.name.startup`
]
Through a block list:
# my.project.settings.py
AUTO_IMPORT = 'startup' # Automatically imports `startup.py` in all apps
AUTO_IMPORT_BLOCK_LIST = [
'my.project.app.name', # Won't import `my.project.app.name.startup`
]
This project uses pre-commit, please make sure to install it before making any changes:
pip install pre-commit cd django-app-auto-import pre-commit install
It is a good idea to update the hooks to the latest version:
pre-commit autoupdate
Don't forget to tell your contributors to also install and use pre-commit.
This project has been set up using PyScaffold 4.5. For details and usage information on PyScaffold see https://pyscaffold.org/.