startproject doesn't put settings.py in subdirectory?!

I’m starting to build a simple, minimal django project, and immediately something is off:

django-admin startproject tstAutoPK
cd tstAutoPK/
python manage.py startapp polls

but the directory and files generated are not consistent with Tutorial1:

tree .
.
├── __init__.py
├── __pycache__
│   ├── __init__.cpython-38.pyc
│   ├── settings.cpython-38.pyc
│   ├── urls.cpython-38.pyc
│   └── wsgi.cpython-38.pyc
├── asgi.py
├── db.sqlite3
├── manage.py
├── polls
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
├── settings.py
├── tstAutoPK
├── urls.py
└── wsgi.py

According to the tutorial settings.py, urls.py, wsgi.py should be placed within the tstAutoPK/tstAutoPK/ SUB-directory, but have been placed instead one level up, in tstAutoPK/. this location seems to work (python manage.py runserver works and provides the default page at http://127.0.0.1:8000/).

So which is considered django-esque, the version in the tutorial or the one produced by startproject?

You should already be in your “outer” tstAutoPK when you run startproject and startapp. You don’t cd into the “inner” tstAutoPK directory when running startapp. This will create the structure as described in the tutorial.

Wow, i’ve labored under that misconception for awhile. thanks Ken!

1 Like