【发布时间】:2020-05-11 13:50:25
【问题描述】:
我有一个模板目录和另外两个目录,home 和 diagnostic,每个目录都有自己的 HTML 文件。所以我想知道这是最好的方法还是我做错了?
【问题讨论】:
标签: django templates django-forms django-templates django-views
我有一个模板目录和另外两个目录,home 和 diagnostic,每个目录都有自己的 HTML 文件。所以我想知道这是最好的方法还是我做错了?
【问题讨论】:
标签: django templates django-forms django-templates django-views
您的问题的答案很容易从这个网站SimpleIsBetterThanComplex得到 该网站为初学者提供了简单的学习方式......
【讨论】:
我已经阅读了Two Scoops of Django Best Practices For Django一书,它确实提供了使用 Django 的最佳实践,在模板章节中,有两种布局模板的最佳样式。
2 - 层模板架构,如:
模板/ base.html dashboard.html # 扩展 base.html 简介/ profile_details.html profile_form.html
你正在使用的样式
3 - 层模板架构,例如:
模板/ base.html dashboard.html # 扩展 base.html 简介/ base_profile.html # 扩展 base.html profile_details.html # 扩展 base_profile.html profile_form.html # 扩展 base_profile.html
作者说 2 层架构最适合应用程序之间整体布局一致的网站。 3 层架构最适合每个部分都需要独特布局的网站。
我强烈推荐这本书,了解使用 Djang 的最佳实践。 https://www.amazon.com/Two-Scoops-Django-Best-Practices/dp/0981467342
【讨论】: