Debug Django using PTVS (Python Tools for Visual Studio)

2012-04-06 11:36:47 +08:00
 029xue
The easiest way to debug python - especially easy for programmers get used to Visual Studio - is using PTVS (Python Tools for Visual Studio).
The steps is simple:
1. Download and install it from http://pytools.codeplex.com/
2. Set breakpotints and press F5.
3. Your breakpoint is hit, you can view/change the variables as easy as debug C#/C++ programs.
4. That's all :)

If you want debug Django using PTVS, you need do following steps:
1. In Project settings - General tab, set "Startup File" to "manage.py", the entry point of Django program.
2. In Project settings - Debug tab, set "Script Arguments" to "runserver --noreload". The key point is the "--noreload" here. If you don't set it, your breakpoints then won't be hit.
3. Enjoy it.
4438 次点击
所在节点    Python
4 条回复
029xue
2012-04-06 11:37:08 +08:00
dychenyi
2012-04-06 14:49:47 +08:00
最新版确实能用了,不过导入工程时会把比如一些.svn导入进去,还不知道怎么设置过滤。我现在只能手动修改.pyproj 。
有些地方还是没有pydev + eclipse爽。比如F3查找定位函数。出错定位代码。
029xue
2012-04-06 16:59:00 +08:00
新版本可以直接建立Python project,只会有.sln和.pyproj两个文件,还是比较简洁的。
ayanamist
2012-04-06 21:13:52 +08:00
我觉得目前最好的debugger依旧是pycharm的,可以支持多线程和多进程的代码调试

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/31508

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX