
django是甚麼?
django是一個python的web framework,設計模式使用MTV的架構(model,templete,view),可快速開發一個web server。使用pycharm建立django專案
而在pycharm的版本中,目前只有perfessional版本的對django的支援比較完整,不過我們還是可以用community版來建立,以下教學就是在windows環境中,使用community版本來建立以及debug專案。▼在C槽建立hello_django新專案,並且使用一個新的virtual env環境

▼在venv/script資料夾上按右鍵,打開terminal

▼輸入指令,安裝django
pip.exe install django
▼安裝成功後可以看到多了django-admin.exe和django-admin.py

▼接下來要使用django-admin.exe來建立web server,先回到C:\hello_django\,輸入以下指令
.\venv\Scripts\django-admin.exe startproject webserver
▼產生了webserver這個資料夾

新產生的manage.py非常重要,之後web server都是靠這個檔案來進行操作。
▼到這個階段基本上就可以跑來測測看了,讓我們新增一個debug的config
檔案指定成上一步驟產生的manage.py
參數設定成runserver

▼按下綠色箭頭就可以執行了,在瀏覽器輸入http://127.0.0.1:8000/就可以看到歡迎畫面了

到目前為止一行程式都沒寫就產生出一個web werver,是不是非常簡單。接下來我們就可以依照MTV的架構來新增頁面和程式了。