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://ibb.co/yPqrwwz

2 comments
Comment actions Permalink
Could you please test if the debugger is working on this minimal project?

https://github.com/aresler/django_dbg_test

If it's working, would it be possible to provide a sample project to reporduce the issue?
0
Comment actions Permalink

I solved the problem by removing the .idea directory for this Django project. After restart everything is fine. 

0

Please sign in to leave a comment.