0

我是 django 新手,不确定文件和文件夹的布局有多自由?现在我有

mysite/
      manage.py

      mysite/
            settings.py
            urls.py

      an_app/
            views.py
            models.py

出于某种原因,在 urls.py 中,当我执行“从 an_app 导入视图”时它可以工作,即使视图与“an_app”不在同一个地方。urls.py 基本上只是在整个项目中搜索名为“an_app”的应用程序吗?最后,在 djangobook.com 中,他们使用“来自 mysite.an_app 导入视图”,但这对我不起作用......?它只是提出“没有名为 an_app 的模块”,为什么不呢?

4

1 回答 1

0

There are a lot of good resources online, some approach is slightly different than other. This can be a good starting point: Setting up a Django environment and project structure

Does urls.py basically just search all over the project for a app called "an_app"?

No, urls.py follows the regular python module import system like anything other python code. There is nothing special about urls.py in terms of imports.

于 2013-09-20T21:32:29.397 回答