/  

Django+VScode环境配置和启动第一个Django项目

Django+VScode环境配置和启动第一个Django项目,这个教程仅适用于windows

直奔主题:tips 国内大陆安装可能比较慢。有条件的可以开启v+p+n+下载或者找国内镜像。在dos窗口下执行下面操作如果拒绝访问请用管理员身份运行dos窗口

Django安装

1.想要安装启动Django那么必须得安装好Python这个环境,pyton请自行百度。

2.安装pip 链接https://www.cnblogs.com/baiyuer/p/9606773.html。

3.完成上面直接 pip install django

4.卸载 pip uninstall 加想要卸载的名字 eg:pip uninstall django

vscode 配置

1.vscode根据自身要求来安装所需要的插件

创建Django项目和启动

在vscode命令窗口中输入:django-admin startproject django项目名字自定义

然后,在该路径下会生成一个django项目文件夹

进入你的项目文件夹 cd+项目文件夹名称

  • 备注:
(1)HelloWorld:项目的容器

(2)manage.py:一个实用的命令行工具,可让你以各种方式与该Django项目进行交互。

(3)HelloWorld/init.py:一个空文件,告诉Python该目录是一个Python包

(4)HelloWorld/settings.py:该Django项目的设置/配置。

(5)HelloWorld/urls.py:该Django项目的URL声明,一份由Django驱动的网站“目录”

(6)HelloWorld/wsgi.py:一个WSGI兼容的Web服务器的入口,以便运行你的项目

接下来,在HelloWorld项目路径下开启django服务器, python manage.py runserver 8001(端口号可自行设置)

创建APP指令 :python .\manage.py startapp book book为app名称


在浏览器上输入 http://localhost:8001 ok!!!你的第一个Django项目已经完成。

django安装vscode.png

补充指令

安装包
pip install package_name

查看某个已安装包
pip show --files package_name

检查哪些包需要更新
pip list --outdated

升级包
pip install --upgrade package_name

卸载包
pip uninstall package_name

使用pip –help命令可以查看pip帮助手册

pip --help

Usage:
pip [options]

Commands:
install Install packages. 安装包
download Download packages. 下载包
uninstall Uninstall packages. 卸载包
freeze Output installed packages in requirements format. 按着一定格式输出已安装包列表
list List installed packages. 列出已安装包
show Show information about installed packages. 显示包详细信息
check Verify installed packages have compatible dependencies.检查包的依赖关系是否完整
config Manage local and global configuration.管理配置
search Search PyPI for packages.搜索包
wheel Build wheels from your requirements.
hash Compute hashes of package archives.计算包的hash值
completion A helper command used for command completion.
help Show help for commands.

General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
--log Path to a verbose appending log.
--proxy Specify a proxy in the form [user:passwd@]proxy.server:port.
--retries Maximum number of retries each connection should attempt (default 5 times).
--timeout Set the socket timeout (default 15 seconds).
--exists-action Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort).
--trusted-host Mark this host as trusted, even though it does not have valid or any HTTPS.
--cert Path to alternate CA bundle.
--client-cert Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
--cache-dir

Store the cache data in .
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
--no-color Suppress colored output


标题:Chisaka
作者:Chisaka
地址:https://www.xiaohongyan.cn/articles/2020/05/27/1590557808323.html
声明:博客上的所内容均可免费使用,可注明归属,注明作者或网址这种行为值得赞赏。