django操作使用:
1.终端操作:
下载:
https://www.djangoproject.com/download/
终端:pip install Django==3.1.6
使用:
需要先配置环境变量:
python安装路径下的Scripts放到环境变量里面
安装包下载后操作:
再python安装路径下运行C:\Python\Python36>pip install Django-3.1.6-py3-none-any.whl 这指令解压
终端进入当前要生成的文件夹:
![](https://i-blog.csdnimg.cn/blog_migrate/55bc181314da8f134e6ee271bd9d97d6.png)
django-admin startproject dijangoDay1
django-admin startproject 项目名
运行测试:
H:\django\dijangoDay1>python manage.py runserver 127.0.0.1:8001
运行成功后:
创建一个可以操作应用文件夹:
H:\django\djangoDay1>python manage.py startapp appday1
models.py---主要操作数据库相关
views.py---业务逻辑
setting.py---配置文件
PyCharm加入django项目:
2.PyCharm创建django项目:
出现错误:
C:\Python\Python36\python.exe H:/django/djangoday1/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
解决:
添加 runserver
运行测试:
修改IP地址跟端口:
出现这个需要指定访问IP:
生成模块 完成第一个页面: