我們使用:
django-admin.py startproject testdj
創(chuàng)建項(xiàng)目:

圖片.png
文件分析:
__init__.py : 表示這是一個(gè)Python的包。
manage.py : 提供簡單化的django-admin.py命令,特別是可以自動(dòng)運(yùn)行 DJANGO_SETTINGS_MODULES 和 PYTHONPATH的處理, 而沒有這個(gè)命令, 處理上面的環(huán)境變量是件麻煩的事情。
從這個(gè)項(xiàng)目結(jié)構(gòu)圖中,可以看到testdj下面還有一層testdj,我們的BASE_DIR是,第一層testdj目錄里面。
如果有工程和APP, 那么注意:
aircraftdeMacBook-Pro:TestPython ldl$ tree testdj/
testdj/
├── db.sqlite3
├── manage.py
├── templates
│ ├── base.html
│ ├── ext-1.html
│ ├── hello.html
│ └── index.html
└── testdj
├── TestModel
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
├── __init__.py
├── __init__.pyc
├── helloworld.py
├── settings.py
├── settings.pyc
├── urls.py
├── urls.pyc
├── view.py
├── view.pyc
├── wsgi.py
└── wsgi.pyc
這種是錯(cuò)誤的文件目錄。
下面的才是正確的:
aircraftdeMacBook-Pro:testpython ldl$ tree testdj/
testdj/
├── TestModel
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── admin.py
│ ├── admin.pyc
│ ├── apps.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── models.pyc
│ ├── tests.py
│ └── views.py
├── db.sqlite3
├── manage.py
├── templates
│ ├── base.html
│ ├── ext-1.html
│ ├── hello.html
│ └── index.html
└── testdj
├── __init__.py
├── __init__.pyc
├── helloworld.py
├── settings.py
├── settings.pyc
├── urls.py
├── urls.pyc
├── view.py
├── view.pyc
├── wsgi.py
└── wsgi.pyc
4 directories, 27 files
APP應(yīng)該與manage.py同級(jí)。
5.工程目錄分析:

圖片.png