How to create a django project using vscode

1. Preliminary preparations
1. Install Python, use pip to install pylint and yapf:
pip install pylint yapf
2. Download and install vscode: https://code.visualstudio.com/
3. Install the plug-in Python (officially released by Microsoft). After the installation is complete, click Reload to restart vscode and activate Python. Plug-in

#After installing flake8, when writing code, the editor will prompt where there is an error. If the code format is not standardized, it will also prompt
1. Open the command line
2. Enter pip install flake8
3. After successfully installing flake8, open VScode, File->Preferences->User Settings, in the settings.json file Enter "python.linting.flake8Enabled": true

2. Configure Python environment with vs code]
Set as follows in settings.json:

3. Create a new Django project
Use vs code to open the newly created file, as follows:

Open vs In the Terminal window of code, switch the path to the project path and execute the following command:
django-admin startproject project_name

Continue to execute the following command:
python manage.py startapp app_name

Remarks:
(1) HelloWorld: the container of the project
(2) manage.py: a practical command line tool that allows you to interact with the Django project in various ways to interact.
(3) HelloWorld/init.py: An empty file that tells Python that the directory is a Python package
(4) HelloWorld/settings.py: The settings/configuration of the Django project.
(5) HelloWorld/urls.py: The URL declaration of the Django project, a "directory" of websites driven by Django
(6) HelloWorld/wsgi.py: A WSGI-compatible The entrance to the web server in order to run your project
4. Configure Debug Django environment with vs code
Set as follows in launch.json:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
"version": "0.2.0",
"configurations": [{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost"
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "enter-your-module-name-here",
"console": "integratedTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/HelloWorld/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"8080", //配置Django端口
"--noreload",
"--nothreading"
],
"django": true
},
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"jinja": true
},
{
"name": "Python: Current File (External Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
}
]
}5. Browser view Effect


Recommended related articles and tutorials: vscode tutorial
The above is the detailed content of How to create a django project using vscode. For more information, please follow other related articles on the PHP Chinese website!
Hot AI Tools
Undress AI Tool
Undress images for free
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Clothoff.io
AI clothes remover
Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!
Hot Article
Hot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
How to use VSCode with WSL (Windows Subsystem for Linux)
Aug 01, 2025 am 06:26 AM
InstallWSLandaLinuxdistributionbyrunningwsl--installinPowerShellasAdministrator,thenrestartandsetuptheLinuxdistribution.2.Installthe"Remote-WSL"extensioninVSCodetoenableintegrationwithWSL.3.OpenaprojectinWSLbylaunchingtheWSLterminal,navigat
How to run Python script with arguments in VSCode
Jul 30, 2025 am 04:11 AM
TorunaPythonscriptwithargumentsinVSCode,configurelaunch.jsonbyopeningtheRunandDebugpanel,creatingoreditingthelaunch.jsonfile,andaddingthedesiredargumentsinthe"args"arraywithintheconfiguration.2.InyourPythonscript,useargparseorsys.argvtoacce
What is the difference between VSCode and Visual Studio
Jul 30, 2025 am 02:38 AM
VSCodeisalightweight,cross-platformcodeeditorwithIDE-likefeaturesviaextensions,idealforwebandopen-sourcedevelopment;2.VisualStudioisafull-featured,Windows-onlyIDEdesignedforcomplex.NET,C ,andenterpriseapplications;3.VSCodeperformsfasteronlower-endma
How to debug unit tests in VSCode
Aug 01, 2025 am 06:12 AM
Createormodifylaunch.jsoninVSCodebyopeningtheRunandDebugview,selectingyourenvironment(e.g.,Python,Node.js),andconfiguringitforyourtestframework(e.g.,pytest,Jest).2.Setbreakpointsinyourtestfile,selectthedebugconfiguration,andstartdebuggingwithF5topaus
How to change the font size in vscode?
Aug 02, 2025 am 02:37 AM
TochangethefontsizeinVSCode,useoneofthesemethods:1.OpenSettingsviaCtrl ,(orCmd ,onMac),searchfor"fontsize",andadjustthe"Editor:FontSize"value.2.OpenSettings(JSON)fromtheCommandPalette,thenaddormodify"editor.fontSize":e.g
How to use Markdown preview in VSCode
Jul 29, 2025 am 02:05 AM
To use Markdown preview in VSCode, no additional installation is required. 1. Open or create a .md file; 2. Use Ctrl Shift V (Windows/Linux) or Cmd Shift V (Mac) shortcut keys, or open the preview through the right-click menu and command panel; 3. Preview is updated in real time by default, ensuring that automatic save is enabled to keep synchronized; 4. You can switch the synchronization scrolling function by right-clicking the preview area, and the preview supports GitHub-style Markdown and mathematical formulas (MarkdownAllinOne extension needs to be installed), and can customize the CSS style, which is easy to operate and complete.
How to debug a Python script in VSCode
Aug 16, 2025 am 02:53 AM
To debug Python scripts, you need to first install the Python extension and configure the interpreter, then create a launch.json file to set the debugging configuration, then set a breakpoint in the code and press F5 to start the debugging. The script will be paused at the breakpoint, allowing checking variables and step-by-step execution. Finally, by checking the problem by viewing the console output, adding logs or adjusting parameters, etc., to ensure that the debugging process is simple and efficient after the environment is correct.
How to automatically format Python code in VSCode
Aug 14, 2025 pm 04:10 PM
ToautomaticallyformatPythoncodeinVSCode,installBlackusingpipinstallblack,installtheofficialMicrosoftPythonextension,setBlackastheformatterinsettings.jsonwith"python.formatting.provider":"black",enableformatonsavebyadding"edit


