Home > Software engineering >  Django can not import site module
Django can not import site module

Time:06-28

I am trying to run a simple Hello World app with Django but for some reason, it does not import myapp from mysite.

enter image description here

CodePudding user response:

You don't need that import, because include imports it from string by itself. Just delete from mysite import myapp and you should be good to go. You are not supposed to import folders, just files from them.

PS please, don't post such pictures, include code with maybe small picture of your structure if you must.

CodePudding user response:

The idea behind include() is to make it easy to plug-and-play URLs. Since polls are in their own URLconf (polls/urls.py), they can be placed under “/polls/”, or under “/fun_polls/”, or under “/content/polls/”, or any other path root, and the app will still work. So, you don't have to import myapp from mysite.

  • Related