【问题标题】:can one have multiple html files in a single template directory in django?在 django 的一个模板目录中可以有多个 html 文件吗?
【发布时间】:2020-05-11 13:50:25
【问题描述】:

我有一个模板目录和另外两个目录,home 和 diagnostic,每个目录都有自己的 HTML 文件。所以我想知道这是最好的方法还是我做错了?

Link to access the directory structure

【问题讨论】:

    标签: django templates django-forms django-templates django-views


    【解决方案1】:

    您的问题的答案很容易从这个网站SimpleIsBetterThanComplex得到 该网站为初学者提供了简单的学习方式......

    【讨论】:

    • 是的,这对初学者来说真的很好,很高兴您的回答
    【解决方案2】:

    我已经阅读了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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-27
      • 1970-01-01
      • 2016-12-10
      • 2020-07-07
      • 1970-01-01
      • 2017-04-10
      • 2016-12-24
      相关资源
      最近更新 更多