[Django]-How to put a breakpoint on django-rest-framework package in vscode to debug?

2πŸ‘

βœ…

I don’t know something specific to VSCode but you can use Pudb to step into an external library like below:

1: Install Pudb by command below:

pip install pudb

2: Import set_trace function from Pudb module into the view.py or anywhere you want to debug like this:

from pudb import set_trace

3: Call set_trace() function anywhere of your code

4: Run python manage.py runserver by Pudb module like:

python -m pudb manage.py runserver
πŸ‘€Ehsan Ahmadi

1πŸ‘

In the latest VSCode and Python extension, open launch.json and add new configuration with parameter "django": true, as in example:

    {
      "name": "Python: Django",
      "type": "python",
      "request": "launch",
      "program": "${workspaceFolder}/server/manage.py",
      "args": [
        "runserver",
        "0:8000"
      ],
      "django": true
    },
πŸ‘€Spatz

Leave a comment