- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Django (2, 2, 4, 'final', 0)
在 docker 中,但我可以在里面猛击以打开或执行所需的任何内容。但是我不能调试。 ( How to debug in Django, the good way? 陈述了一些方法,没有对我有用)
在我的 views.py
内我有各种功能,例如这里的这个。
def visGraph(request):
showgraph = 'Graphen'
selectDB = request.GET.get('selectDB', '')
__import__("pdb").set_trace()
title += " <i>"+showgraph+"</i> ("+selectDB+")"
> /code/DjangoGraphen/views.py(74)visGraph()
-> title += " <i>"+showgraph+"</i> ("+selectDB+")"
(Pdb)
Internal Server Error: /DjangoGraphen/visGraph
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "./DjangoGraphen/views.py", line 74, in visGraph
title += " <i>"+showgraph+"</i> ("+selectDB+")"
File "./DjangoGraphen/views.py", line 74, in visGraph
title += " <i>"+showgraph+"</i> ("+selectDB+")"
File "/usr/lib64/python3.7/bdb.py", line 88, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/lib64/python3.7/bdb.py", line 113, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
ERROR:django.request:Internal Server Error: /DjangoGraphen/visGraph
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "./DjangoGraphen/views.py", line 74, in visGraph
title += " <i>"+showgraph+"</i> ("+selectDB+")"
File "./DjangoGraphen/views.py", line 74, in visGraph
title += " <i>"+showgraph+"</i> ("+selectDB+")"
File "/usr/lib64/python3.7/bdb.py", line 88, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/lib64/python3.7/bdb.py", line 113, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
[21/Oct/2019 17:47:14] "GET /DjangoGraphen/visGraph?selectDB=Test&showgraph=graph HTTP/1.1" 500 88178
__import__("pdb").set_trace()
没有太大关系或
breakpoint()
- 两者都返回相同的结果。
DEBUG = True
,将其设置为
False
不会改变任何东西。
docker logs django_web_1 -f
最佳答案
解决方案实际上相当简单。问题是 docker 。解决方案在此处说明并且有效:
https://medium.com/@vladyslav.krylasov/how-to-use-pdb-inside-a-docker-container-eeb230de4d11
将此添加到您的 docker-compose.yml 中:
ports:
- "4444:4444"
stdin_open: true
tty: true
remote-pdb
并使用您的默认 pdb 命令代替:
__import__("remote_pdb").set_trace(host='0.0.0.0', port=4444)
telnet 0.0.0.0 4444
关于python - 无法在 Django 中调试或使用 pdb : bdb. BdbQuit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58491870/
我正在使用 Django (2, 2, 4, 'final', 0)在 docker 中,但我可以在里面猛击以打开或执行所需的任何内容。但是我不能调试。 ( How to debug in Djang
最近将 pdb 调试器添加到我的 Python 2.7.10 代码时,我收到以下消息: Traceback (most recent call last): File "/Users/isaach
我正在使用 Flask-SocketIO我项目中的库。因为 websockets 需要与主 Flask 应用程序“并行运行”,所以我需要使用 gevent-websocket图书馆。当我尝试在 cre
我是一名优秀的程序员,十分优秀!