Django 断点不起作用 PyCharm

Posted

技术标签:

【中文标题】Django 断点不起作用 PyCharm【英文标题】:Django Breakpoints Not Working PyCharm 【发布时间】:2017-07-10 10:51:03 【问题描述】:

我正在尝试在 PyCharm 中调试 Django 项目。我在 Django 告诉我异常来自的地方设置了一个断点。但是当我点击调试时,断点变成灰色,调试器没有捕捉到它。

但这正是导致错误的行,你相信我的堆栈跟踪。

追溯:

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  217.                 response = self.process_exception_by_middleware(e, request)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  215.                 response = response.render()

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/response.py" in render
  109.             self.content = self.rendered_content

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/response.py" in rendered_content
  86.         content = template.render(context, self._request)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render
  208.                     return self._render(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/loader_tags.py" in render
  174.         return compiled_parent._render(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/defaulttags.py" in render
  315.                 return nodelist.render(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/defaulttags.py" in render
  439.             url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/urls/base.py" in reverse
  91.     return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))

File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/urls/resolvers.py" in _reverse_with_prefix
  392.             (lookup_view_s, args, kwargs, len(patterns), patterns)

Exception Type: NoReverseMatch at /Bar/login/
Exception Value: Reverse for 'dashboard' with arguments '()' and keyword arguments '' not found. 0 pattern(s) tried: []

我已启用所有可能导致执行不停止的选项

我已经尝试删除 .idea 文件。

有人知道为什么 PyCharm 不能识别这个断点吗?

【问题讨论】:

【参考方案1】:

当您的断点标记为灰色时,表示它们已静音。要取消静音,您应该在调试控制台中寻找“静音断点”按钮。

这个图标是一个用斜线标记的断点。

【讨论】:

对不起,我不是很清楚。当我按下调试时,它们不会静音。之后他们变得静音。其他原因导致他们静音。 哦,我明白了。直到我一直不明白静音断点是如何工作的。 是的,我认为这是将断点标记为灰色的唯一方法。

以上是关于Django 断点不起作用 PyCharm的主要内容,如果未能解决你的问题,请参考以下文章

“添加断点”快捷方式在 xcode 4.3 中不起作用

python-django模板继承在引用基中的多个块时不起作用

为啥 Xcode 断点不起作用?

Xamarin.Forms ImageButton 不起作用,单击不起作用,调试断点仅在 iOS 上根本不会被命中

断点在 Qt Creator 中不起作用

顺风响应断点不起作用