Run Django server using the run button in visual studio code

In pyCharm we have this option where we can configure Run button to start the server by adding the same to the script path.

enter image description here

I wanted to do the same in visual studio code, so that whenever I click Run, my django server gets started.


Solution 1:

You need to create a launch.json in the folder .vscode which sits in the same folder as your manage.py.

// Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}\\manage.py",
            "args": [
                "runserver",
            ],
            "django": true
        },
    ]
}

You can create one by clicking run & debug and then at top menu green triangle click add configuration, python, Django