什么是正确的Django项目/应用结构

时间:2018-09-30 00:15:17

标签: django

Django的新手,Python的新手。从Symfony / PHP和MVC / C#迁移过来只是因为它有所不同。

因此,我正在启动一个应用程序,该应用程序将不会用作任何其他应用程序的一部分。在本教程中继续学习,似乎Django似乎希望我将每个URL都放在App上。例如:

/directors
/ledgers

之所以说Django希望我使用每个URL系列一个App,是因为在本教程中,视图/模型/模板位于该App中,并使用index.html / details.html等,例如所以

polls --> templates --> index.html
                        details.html

以Symfony为例,在模板中,我可以像这样分支到其他文件夹。

views --> directors --> index.html
                        details.html
          ledgers   --> index.html
                        details.html

对于Django,我将如何处理同一场景?只是为每个模板命名不同?例如:

polls --> templates --> directors_index.html
                        directors_details.html
                        ledgers_index.html
                        ledgers_details.html

还是我将每个移动到他们自己的应用程序?非常困惑。

1 个答案:

答案 0 :(得分:0)

对话很便宜,为什么不让我给你看一张照片呢? enter image description here