我试图确定为什么我在调用时不能使用调试器:
python manage.py dumpdata --indent=2 > forum/fixtures/initial_data.json'
我在管理命令代码中添加了以下语句:
import pdb; pdb.set_trace()
# I also tried
import ipdb; ipdb.set_trace()
调用该命令时,该命令会挂起,必须使用 ctl-C 停止:
$ python manage.py dumpdata --indent=2 > forum/fixtures/initial_data.json
^CERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (55, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (101, 0))
为什么调试器不工作?
最佳答案
您正在将输出重定向到文件。
如果你查看 forum/fixtures/initial_data.json 的比赛,你会看到 pdb 在那里要求输入。如果要调试转储数据,请不要重定向输出。
关于django - 为什么我不能使用 'dumpdata' 管理命令进入调试器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10504646/