PyCharm debugger doesn't hit breakpoints inside the views.py with Django 关注
I have a very simple django project with one app. I added this app to INSTALLED_APPS list in settings.py.
views.py
from django.http.response import HttpResponse, HttpResponseNotFound, HttpResponseRedirect
sections = {
'finance': 'This is finance section',
'software': 'This is software section',
'sports': 'This is sports section'
}
def newsroom_view(request, section):
try:
return HttpResponse(sections[section])
except:
return HttpResponseNotFound(f"Section {section} doesn't exist. Sorry!")
def newsroom_view_num(request, topic_num):
topics = list(sections.keys())
return HttpResponseRedirect(topics[topic_num])
I've set the breakpoint in this line:
return HttpResponse(sections[section])
PyCharm never stops on breakpoint, the response is loaded as normal in the browser.
However, if I manually set the breakpoint using pdb, it stops:
breakpoint()
return HttpResponse(sections[section])
Here is my debug configuration:
请先登录再写评论。
https://github.com/aresler/django_dbg_test
If it's working, would it be possible to provide a sample project to reporduce the issue?
I solved the problem by removing the .idea directory for this Django project. After restart everything is fine.