创建虚拟环境
配置虚拟环境
1.安装虚拟环境模块
pip install virtualenv -i https://pypi.douban.com/simple/
pip install virtualenvwrapper-win -i https://pypi.douban.com/simple/
2.创建空文件夹(自己创建即可)
3.配置环境变量
创建虚拟环境
1.创建虚拟环境
mkvirtualenv 虚拟环境名
2.显示所有虚拟环境
workon
3.进入指定虚拟环境
workon 虚拟环境名
4.退出虚拟环境
deactivate
安装Django
pip install django==3.1.7 -i https://pypi.douban.com/simple/
1.创建项目
django-admin startproject 项目名
2.启动django
(1)从终端启动
python manage.py runserver
(2)配置PyCharm启动
如果不配置会出现以下情况
D:\pythonvens\python.exe D:/djangoProject/cheng/manage.py
Type 'manage.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[auth]
changepassword
createsuperuser
[contenttypes]
remove_stale_contenttypes
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver
Process finished with exit code 0
解决方法:
在parameters这里输入runserver即可,这样就可以右键 run 和 debug 了
安装成功后如下:
复制蓝色链接到浏览器,就可以看到运行结果了
这样恭喜你创建了属于自己django项目。