Django Learning Diary 1 -- Initi

2019-01-05  本文已影响0人  大象小牙

工具:VScode

环境:virtualenv,python,django

步骤:

1. 配置Virtualenv:

> Get-ExecutionPolicy

> Set-ExecutionPolicy remoteSigned then choose 'A'


> django-admin startproject projectName

> python manage.py startapp app

2. 安装vscode

3. 在vscode里分别安装Material Icon Theme, Son of Obsidian Theme, Python, Django,XML Tools, Beautify, View In Browser, HTML CSS Support, Path Intellisense

4. Vscode interface configuration:

在setting里输入:


{

    "editor.fontSize": 16,

    "explorer.confirmDragAndDrop": false,

    "extensions.autoUpdate": false,

    "workbench.colorTheme": "Son of Obsidian",

    "editor.fontFamily": "Consolas, Dengxian",

    "workbench.sideBar.location": "left",

    "workbench.startupEditor": "newUntitledFile",

    "workbench.iconTheme": "material-icon-theme",

}

5. 配置python环境:选择做导航栏第四个图标(或按Ctrl+Shift+D),在DEBUG右边选择Python。

Initialising python
此时在文件中会弹出.vscode文件夹,里面有2个文件,分别为launch.json 和settings.json(可能不会自动生成,可以自己添加)            
automaticly generated config files
在launch.json里找到Python.Django,并在‘args’加入端口号‘8080’(可为其他)
Add Port number
在settings.json里将interpreter改为virtualenv里面的python(注意是双斜杠)
Change python path to virtualenv

6. install 语法检测和代码格式化工具:


> pip install pylint

> pip install pylint_django

> pip install yapf

小结:

  1. 创建虚拟环境来自定义pip安装package
  2. 用Plugins(Material Icon Theme/Son of Obsidian Theme)美化Vscode
  3. 配置Python+Django环境,注意python path和port number;
> django_admin startproject dirName
> python manage.py startapp appName
上一篇下一篇

猜你喜欢

热点阅读