[Django]-Run a Django project from VSCODE

5👍

Here is how I did:
From Terminal -> Configure Tasks…

{
"version": "2.0.0",
"tasks": [
    {
        "label": "Django: Run Server",
        "type": "shell",
        "command": "${config:python.pythonPath}",
        "args":[ 
               "manage.py",
               "runserver"
         ],
        "group": "none",
        "presentation": {
            "reveal": "always",
            "panel": "new"
           }
       }
   ]
}

Afterwards, it should show up, when you select Terminal -> Run Task…

3👍

I’m in Linux if you are different environment please provide approprite command

Ctrl + Shift + p and type >python: Select Interpreter Please select your virtualenv which Django installed.

And Go to Debug ( Ctrl + Shift + d ) and these…

{
    // 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": "Django",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config:python.pythonPath}",
            "program": "${workspaceRoot}/manage.py",
            "cwd": "${workspaceRoot}",
            "args": [
                "runserver",
                "--noreload",
                "--nothreading"
            ],
            "env": {},
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput",
                "DjangoDebugging"
            ]
        }
    ]
}

0👍

If you don’t want to update the changes in VS Code, you can run the command in the Windows terminal:

  • Step 1: Activate the virtual environment (if you are using it)
  • Step 2: Point the directory where manage.py is located and then run the runserver command and you should be good to go.

0👍

I use VS Code and run the project typing python manage.py runserver and everything works smoothly. I’m not aware of having done anything special to make it work this way.
I do work wihin a pip virtual env that i launch by typing pipenv shell.

Whenever i run python manage.py runserver it launches the server at 127.0.0.1:8000.

I assumed it came built-in with django. Maybe it has something to do with how you installed python. I remember having some issue with that some time back. It was about setting the PATH variable in the windows environment.

Leave a comment