django學之路01--環境安裝和pycharm運行django項目

1. 環境安裝python

1).virtualenv安裝django

C:\Users\Administrator>pip install virtualenv
Collecting virtualenv
  Using cached https://files.pythonhosted.org/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv-16.0.0

 

2). 創建虛擬環境app

D:\work\env>virtualenv django_env
New python executable in D:\work\env\django_env\Scripts\python.exe
Installing setuptools, pip, wheel...done.

 

3).進入虛擬環境並安裝django函數

D:\work\env\django_env\Scripts>activate

(django_env) D:\work\env\django\Scripts>pip install django
Collecting django
  Using cached https://files.pythonhosted.org/packages/bf/e0/e659df5b5b82299fffd8b3df2910c99351b9308b8f45f5702cc4cdf946e9/Django-1.11.14-py2.py3-none-any.whl
Collecting pytz (from django)
  Using cached https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl
Installing collected packages: pytz, django
Successfully installed django-1.11.14 pytz-2018.5

 

2. pycharm建立django項目單元測試

1)建立項目測試

 

2) 項目結構url

上面djangoProject:項目名稱,可修改spa

apps:項目名稱,若是分多個模塊,一般放在該目錄下3d

tests:應用下單元測試用例code

views:應用視圖函數

下面djangoProject:項目實際的python,最好不要修改,涉及配置問題

settings:項目全局配置文件

urls:項目全局路由

wsgi:項目wsgi配置

template:配置模板文件

manage:程序入口

相關文章
相關標籤/搜索