1.django 默认的runserver使用的是http协议,如果需要https协议,需要以下3个库
pip install django-extensions
pip install django-werkzeug-debugger-runserver
pip install pyOpenSSL
2.配置settings文件 在INSTALLED_APPS下添加
‘werkzeug_debugger_runserver’,
‘django_extensions’,
3. 在终端使用命令运行
python manage.py runserver_plus --cert server.crt 0.0.0.0:8000
或者使用本地ip
python manage.py runserver_plus --cert server.crt 127.0.0.1:8888
python manage.py runserver_plus --cert server.crt 10.10.8.176:8888
(10.10.8.176:8888 本地ip:自定端口)
4.访问提示,不是私密连接。可点击高级—继续前往127.0.0.1(不安全)
原文链接:https://blog.youkuaiyun.com/qq_38059635/article/details/88075449