Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use visual studio code to debug django

Tags:

I'm new at django development and come from desktop/mobile app development with Xcode and related IDE.

I have to use Django and I was wondering if there was an efficient way to debug it using Visual Studio Code (or Atom).

Any help related to Django IDE would be helpful too.

like image 817
DEADBEEF Avatar asked Dec 02 '16 17:12

DEADBEEF


People also ask

Can I debug Python in VS Code?

Start by clicking on the debug icon on the left-hand panel of your VSCode. Click on create a launch. json file, which will give you a drop-down of all your currently installed debuggers. By default, a Python debugger is not installed in VSCode.

How do you run in debug mode in Visual Studio Code?

To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D. The Run and Debug view displays all information related to running and debugging and has a top bar with debugging commands and configuration settings.

Is VS Code good for Django?

The best thing about VScode is that it comes with a built-in terminal which comes handy for Django projects press Ctrl+Shift+` to invoke the terminal. Note that in windows powershell may seem weird for new users it is recommended to use Python debug console or CMD.


1 Answers

For VSCode (full disclosure, I'm one of the VSCode developers) try installing the Python extension to get started.

This documentation covers debugging Django. There should be a included debug configuration or you can add your own to the launch.json file:

{     "name": "Django",     "type": "python",     "request": "launch",     "stopOnEntry": false,     "pythonPath": "${config.python.pythonPath}",     "program": "${workspaceRoot}/manage.py",     "args": [         "runserver",         "--no-color",         "--noreload"     ],     "debugOptions": [         "WaitOnAbnormalExit",         "WaitOnNormalExit",         "RedirectOutput",         "DjangoDebugging"     ] } 

The Python extension also provide many other features that you may find useful.

Hope that helps you get started.

like image 125
Matt Bierner Avatar answered Oct 09 '22 15:10

Matt Bierner