我正在使用Django蜜罐(https://github.com/jamesturk/django-honeypot),想知道如何定制honeypot_error.html页面(https://github.com/jamesturk/django-honeypot/blob/master/honeypot/templates/honeypot/honeypot_error.html),它在蜜罐检测失败时执行。谢谢!!
发布于 2020-08-13 16:33:17
如果您的项目中有具有相同结构化路径templates/honeypot/honeypot_error.html的honeypot_error.html,它会将您的页面作为默认页面。(请参阅要注意的关键点:here )
示例: package x在templates/myapp/toto.html中定义一个名为toto.html的模板
在您的应用程序中,在templates/myapp/toto.html中添加自定义toto.html
当调用
python manage.py collectstatic它将获取您的模板,而不是myapp默认提供的模板
发布于 2020-08-17 08:48:58
我不能对MSR974的回答发表评论,因为:
来自Django关于overriding templates的文档
from pathlib import Path
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
INSTALLED_APPS = [
...,
'blog',
...,
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
...
},
]注意:“如果你的应用和项目模板目录都包含覆盖,默认的Django模板加载器将首先尝试从项目级目录加载模板。换句话说,在搜索之前搜索APP_DIRS DIRS。”
在阅读示例时,请记住应用程序模板和项目模板之间的区别,并确保您已根据所选策略配置了设置。
https://stackoverflow.com/questions/63330522
复制相似问题