Django:模板文件的推荐放置位置?
Django 似乎没有关于模板文件放置的约定。什么是最合乎逻辑、首选的放置位置?
(由于 Django 强调应用程序的互操作性,我认为“最佳”位置应该是 /app/
下的某个位置;也许是 /app/templates/
?)
It seems that Django doesn't have a convention on the placement of template files. What would be the most logical, preferred placement?
(Since Django stresses the interoperability of apps, I assume that the "best" placement would be somewhere under /app/
; maybe /app/templates/
?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为 django 项目下的最佳实践,模板应存储在
$project_dir/templates/
目录下,因为默认情况下 django 会扫描每个$application_dir/templates
目录中的模板。这样您的项目和应用程序目录结构之间就有了约定。希望这是有道理的。As best pracice under your django project, the templates should be stored under
$project_dir/templates/
directory because by default django scans templates from every$application_dir/templates
directory. That way you have a convention between your project and application directory structure. Hope that makes sense.