Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
似乎 Django 对模板文件的放置没有约定。什么是最合乎逻辑的首选位置?
(由于 Django 强调应用程序的互操作性,我认为“最佳”位置应该在/app/; 也许/app/templates/?)
/app/
/app/templates/
作为 django 项目下的最佳实践,模板应该存储在$project_dir/templates/目录下,因为默认情况下 django 会从每个$application_dir/templates目录中扫描模板。这样,您的项目和应用程序目录结构之间就有了约定。希望这是有道理的。
$project_dir/templates/
$application_dir/templates