什么是正确的Django项目/应用程序结构 [英] What is the proper Django Project/App Structure

查看:43
本文介绍了什么是正确的Django项目/应用程序结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

New to Django, new to Python. Moving from Symfony/PHP and MVC/C# just because it's something different.

因此,我正在启动一个应用程序,该应用程序将不会用作任何其他应用程序的一部分.在教程中紧随其后,似乎Django似乎要我在App上放置每个URL.例如:

So I'm starting an App, this app will not be used as a piece of any other app. Following along in the tutorial it almost seems like Django wants me to put each url as it's on App. For example:

/directors
/ledgers

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

The reason I say it seems like Django wants me to use an App per url family is because in the tutorial the views/models/templates are in the App, and use use index.html/details.html, etc, like so

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

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

Whereas in Symfony for example, in the templates I'd be able to branch to other folders like so.

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

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

For Django how would I handle the same scenerio? Just name each template different? For example:

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

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

Or would I move each to their own App? Very confused.

推荐答案

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

Talk is cheap , why not let me just show you a picture.

这篇关于什么是正确的Django项目/应用程序结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆