Django:模板文件的推荐放置位置?

发布于 2024-08-10 23:22:23 字数 154 浏览 6 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奈何桥上唱咆哮 2024-08-17 23:22:23

作为 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文