manage.py - not in project folder?

holyredbeard picture holyredbeard · Feb 27, 2013 · Viewed 7.4k times · Source

I'm trying out Django for the first time, and I'm trying to follow the tutorial provided by the django team.

After I've created a new project I get the following folder/file structure, just as the tutorial says I should:

mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        wsgi.py

When I create an app I run:

python manage.py startapp polls

...which creates the app 'polls' in the same folder as the manage.py file - which gives me:

mysite/
    manage.py
    polls/
        __init__.py
        admin.py
        models.py
        tests.py
        views.py
    mysite/
        __init__.py
        settings.py
        urls.py
        wsgi.py

This means the app I created gets created outside my project folder, which, of course, should not be the case. I have tried to move manage.py inside the project folder. But when I do that and run:

python manage.py syncdb

...I get the following error:

raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" %     (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'testproject.settings' (Is it on sys.path?): No     module named testproject.settings

I guess I could move the app manually to the project folder, but this is something I shouldn't have to do.

So, either something is wrong in the tutorial (which I have very hard to believe), or I'm missing something out here (more likely).

Thanks in advance.

Answer

katy lavallee picture katy lavallee · Feb 27, 2013

This is the new proper layout. "mysite/mysite" is an app, and "mysite/polls" is an app. The "mysite" parent folder is your project folder.