我正在尝试使用名为django-admin-tools
的模块。它需要我将'admin_tools.template_loaders.Loader'
放在我的模板顶部。我有AppDirs: True
这意味着我不能在模板的选项部分使用'loaders'
选项。当'admin_tools.template_loaders.Loader'
设置为AppDirs
时,我在哪里可以放置True
?
根据this doc,当APP_DIRS
为True时,这意味着django只使用django.template.loaders.app_directories.Loader
。
所以我认为你没有必要设置APP_DIRS
True。只需将loaders
中的装载机附加到admin_tools.template_loaders.Loader
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': False,
'OPTIONS': {
...,
'loaders': [
'django.template.loaders.app_directories.Loader',
'admin_tools.template_loaders.Loader',
...
],
},
},
]