0

Im using the latest PyCharm 2016.2. I working on Django site with several app, and I want to debug a line in the models.py:

models.py

class LocationPolygon(models.Model):
    title = models.CharField(max_length=30)
    mpoly = models.MultiPolygonField(srid=4326, null=False, blank=False)
    objects = models.GeoManager()

    def get_tooltip_title(self):
        <some bugy code here>
        return ""

    def __unicode__(self):  # __unicode__ on Python 2
        return self.title + " | " + self.get_tooltip_title()

I want to debug the line "some bugy code here" just inside the function "get_tooltip_title", but when I press the debug button nothing happens and there is exit code 1 in the debug console...

  • Where are you setting the break point? Most likely the code has already broken before getting to the bp – Sayse Aug 08 '16 at 15:07
  • please see my edit. And no, I think the debugger does not getting to the break point at all, it is just showing "exit code 1" - success... –  Aug 08 '16 at 15:13
  • Possible duplicate of [how do i debug/breakpoint my django app using pycharm?](http://stackoverflow.com/questions/11254491/how-do-i-debug-breakpoint-my-django-app-using-pycharm) – trinchet Aug 08 '16 at 15:55
  • But I need to debug the models.py part not the end part like the views/forms... –  Aug 08 '16 at 16:09

3 Answers3

0

I think models will be loaded before the execution of your views, most likely it will check the models while initialization of the Project. That said you can always user break points anywhere you like in pycharms.

If this is not working you manually break and trace execution using pbd. Here and here are good post to start with on how to use pdb.

Community
  • 1
  • 1
kt14
  • 838
  • 15
  • 25
0

It just means that the error is happening before the breakpoint. What's the stack trace?

0

The following steps helped me to start debug:

  1. Changing the debug configurations in: enter image description here

To: enter image description here

And that is it.

Community
  • 1
  • 1