django grappelli change_form.html覆盖 [英] django grappelli change_form.html override
问题描述
我正在尝试扩展django的admin change_form.html(django / contrib / admin / templates / admin / change_form.html)。
什么使这更复杂对于我来说,我已经安装了grappelli,它也扩展了它(grappelli / templates / admin / change_form.html)
现在,我想在myproject申请项目中的所有应用程序/模块),并尝试将change_form放在各个地方,但无效:
- myproject /模板/ admin / change_form.html
- myproject / templates / grappelli / change_form.html
- myproject / templates / admin / grappelli / change_form.html
有没有人知道我应该放置我的修改版本的change_form.html,以便django实际使用它? / p>
(了解django的搜索路径和模板扩展机制的任何帮助将不胜感激)。
谢谢! / p>
您可以将您的模板目录添加到 TEMPLATE_DIRS
TEMPLATE_DIRS =(
os.path.join(BASE_DIR,'myapp / templates /'),
)
这样,您可以更改Django读取模板文件的顺序。
I'm trying to extend django's admin change_form.html (django/contrib/admin/templates/admin/change_form.html).
What makes this more complicated for me is that I've installed grappelli, which also extends it (grappelli/templates/admin/change_form.html)
Now, I want to change it in myproject (to apply for all apps/modules in my project), and have tried to place change_form in various places but to no avail:
- myproject/templates/admin/change_form.html
- myproject/templates/grappelli/change_form.html
- myproject/templates/admin/grappelli/change_form.html
Does anyone have a clue about where I should be placing my modified version of change_form.html in order for django to actually use it?
(any help on understanding django's search path & template extension mechanism will be appreciated).
Thanks!
You can include your template directory to TEMPLATE_DIRS
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'myapp/templates/'),
)
This way you can change the order in which Django reads your template files.
这篇关于django grappelli change_form.html覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!