简体   繁体   中英

Django Breakpoints Not Working PyCharm

I'm trying to debug a Django project in PyCharm. I've set a breakpoint at the point where Django tells me that the exception is coming from. When I hit debug though, the break point turns grey, and the debugger doesn't catch it.

灰色断点

But this is exactly the line which is causing the error, it you believe my stack trace.

Traceback:

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: []

I've enabled every option that might be causing execution to not stop

已选择选项 更多选择

And I've tried removing the .idea file.

Does anyone have any idea about why PyCharm isn't recognising this break point?

When your breakpoint are marked as gray, that means that they are muted. To unmute them, you should look for the button "Mute Breakpoints" in the debug console.

This icon is a breakpoint marked with a tilted line.

I was in trouble with such matter too and I have tried others suggestions finally I found the best way

I am using pycharm 2021 and wherever I want to have breakpoint I write this code

breakpoint()

for example

#some code

breakpoint()

#other codes

then program stops and in terminal it is mentioned where program is stopped

after that you cant trace your code piece by piece

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM