pip install django_components
settings
add following: STATICFILES_DIRS += os.path.join(BASE_DIR, "components")
settings
remove APP_DIRS
from TEMPLATES
variable: "APP_DIRS": True,
settings
add loaders
and builtins
in TEMPLATES
variable:TEMPLATES = [
{
...
"OPTIONS": {
"context_processors": [
...
],
"loaders": [
(
"django.template.loaders.cached.Loader",
[
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
"django_components.template_loader.Loader",
],
)
],
"builtins": [
"django_components.templatetags.component_tags",
],
},
},
]
💡Note that this module is incompatible with django-debug-toolbar because it requires APP_DIRS
to function, which is removed for this plugin. so alternatively django.template.loaders.app_directories.Loader
can be added to fix the issue:
TEMPLATES = [
{
...
"OPTIONS": {
...
"loaders": [
"django.template.loaders.app_directories.Loader",
...
],
},
},
]