Pages

How to run Django Server from VSCode

 Hi Noonari, 

Here is how  I did it.


Step 1. Install following plugins

  • Python (by microsoft)
  • Live Server
Step 2. Set python version to your virtual env by following these steps in bullets in order
  1. Press `CTRL+SHIFT+P`
    This will open a command pallet in vscode.
  2. Set the python version by selecting if it is visible in the dropdowns or by typing it like
    `Python > <path-to-venv>/bin/python`
  3. create launch.json (normally it is automatically created when you press run button so first press run and see if it runs or not and then check or create launch.json)
  4. add this as contents of launch.json
    {
        // 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}/monolith/manage.py",
                "args": [
                    "runserver",
                    "--noreload"
                ],
                "django": true,
                "justMyCode": true
            }
        ]
    }
Step 3. Run and test.

No comments:

Post a Comment