快速初始化一个项目:cookiecutter
示例来源于 cookiecutter-django项目
usage
pip install "cookiecutter>=1.7.0"
cookiecutter https://github.com/cookiecutter/cookiecutter-django
环境提供:local、production
网络
pycharm 使用 debug 模式的时候提示
2024-01-26T03:11:17.734227227Z PostgreSQL is available
2024-01-26T03:11:19.879595402Z Could not connect to host.docker.internal: 61147
2024-01-26T03:11:19.880258821Z Traceback (most recent call last):
2024-01-26T03:11:19.881026471Z File "/opt/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 463, in start_client
2024-01-26T03:11:19.881269144Z s.connect((host, port))
2024-01-26T03:11:19.881290110Z socket.gaierror: [Errno -2] Name or service not known
2024-01-26T03:11:19.881302169Z Could not connect to host.docker.internal: 61147
2024-01-26T03:11:19.882321658Z Traceback (most recent call last):
2024-01-26T03:11:19.883283788Z File "/opt/.pycharm_helpers/pydev/pydevd.py", line 2206, in main
2024-01-26T03:11:19.883365970Z debugger.connect(host, port)
2024-01-26T03:11:19.883386459Z File "/opt/.pycharm_helpers/pydev/pydevd.py", line 670, in connect
2024-01-26T03:11:19.883393351Z s = start_client(host, port)
2024-01-26T03:11:19.883398270Z ^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-26T03:11:19.883471870Z File "/opt/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 463, in start_client
2024-01-26T03:11:19.883483991Z s.connect((host, port))
2024-01-26T03:11:19.883490028Z socket.gaierror: [Errno -2] Name or service not known
我在 local.yml文件中针对 django service 加入如下配置可以解决
extra_hosts:
- "host.docker.internal:host-gateway"
这是再重新使用 debug 模式启动即可
断点调试
ipdb
import ipdb; ipdb.set_trace()
pycharm