django应用程序文件结构 [英] django app file structure
本文介绍了django应用程序文件结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是一个常见的应用程序文件结构:
Below is a common app file structure:
app/
views.py
forms.py
urls.py
tests.py
我发现这很难代码库越来越大,维护代码。我正在考虑根据个人网页来组织代码,所以每个网页都有自己的view.py,form.py和test.py。
I found it's getting hard to maintain the code once the code base is getting big. I am thinking to organize the code based on individual web page, so each web page will have its own view.py, form.py and test.py.
app/
views/
page1_view.py
page2_view.py
forms/
page1_form.py
page2_form.py
tests/
page1_test.py
page2_test.py
有没有什么大问题我会遇到?
Is there any big issue I will run into?
推荐答案
不。 Django了解包和文件。
No. Django understands packages and files.
如果您使用
app/
views/
page1_view.py
page2_view.py
__init__.py
您可以将视图引用为app.views.page1_views,没有任何问题。
you can reference the views as app.views.page1_views without any issues.
这篇关于django应用程序文件结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文