0

I am new to django and am uncertain about how free the layout of files and folders can be? Right now i have

mysite/
      manage.py

      mysite/
            settings.py
            urls.py

      an_app/
            views.py
            models.py

For some reason, in urls.py, when i do "from an_app import views" it works, even though views is not in the same place as "an_app". Does urls.py basically just search all over the project for a app called "an_app"? Lastly, in the djangobook.com they use "from mysite.an_app import views" but this does NOT work for me...? it just comes up with "No module named an_app" why not?

1 Answers1

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.

zengr
  • 38,346
  • 37
  • 130
  • 192
  • in which case, how did urls.py find an_app if it is in a different directory? Thanks! – Caspar Wylie Sep 20 '13 at 21:36
  • Not sure what you mean there, can you give an example? See newsblur's urls.py: https://github.com/samuelclay/NewsBlur/blob/master/urls.py and notice how `apps.reader` is imported. – zengr Sep 20 '13 at 21:42