**Want to set up Django in VS Code? Here's a complete step-by-step guide!**
In this tutorial, I'll show you **how to install and run Django in Visual Studio Code (VS Code)**. Whether you're a beginner or an experienced developer, this guide will help you get started with Django development smoothly.
---
### ** What You’ll Learn:**
How to **install Python and Django**
How to **set up a Django project in VS Code**
How to **run the Django development server**
How to **use the VS Code terminal for Django commands**
How to **fix common setup issues**
---
### ** Prerequisites:**
**Python Installed** ([Download here](https://www.python.org/))
**Visual Studio Code Installed** ([Download here](https://code.visualstudio.com/))
**Basic Knowledge of Python (Optional)**
---
## **Step 1: Install Python and VS Code**
1⃣ Download and install **Python** from [python.org](https://www.python.org/downloads/)
2⃣ Install **VS Code** from [code.visualstudio.com](https://code.visualstudio.com/)
3⃣ Open VS Code and install the **Python extension** from the Extensions Marketplace
---
## **Step 2: Install Django in VS Code**
1⃣ Open **VS Code** and launch the terminal (**Ctrl + `**)
2⃣ Create a virtual environment (Recommended)
```bash
python -m venv venv
```
3⃣ Activate the virtual environment:
- **Windows:**
```bash
venv\Scripts\activate
```
- **Mac/Linux:**
```bash
source venv/bin/activate
```
4⃣ Install Django:
```bash
pip install django
```
5⃣ Verify Django installation:
```bash
django-admin --version
```
---
## **Step 3: Create a New Django Project**
Run the following command to create a Django project:
```bash
django-admin startproject myproject
```
Navigate into the project folder:
```bash
cd myproject
```
Run the Django development server:
```bash
python manage.py runserver
```
---
## **Step 4: Open Django Project in VS Code**
1⃣ Open the **myproject** folder in VS Code
2⃣ Install the following VS Code extensions (recommended):
- **Python**
- **Django**
- **Pylance**
3⃣ Use the integrated terminal to run Django commands
---
## **Step 5: Create a Django App**
Inside your Django project folder, create a new app:
```bash
python manage.py startapp myapp
```
Register the app in `settings.py` under `INSTALLED_APPS`:
```python
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
...
'myapp',
]
```
---
## **Step 6: Run the Django Server & Open in Browser**
1⃣ Start the Django server:
```bash
python manage.py runserver
```
2⃣ Open your browser and go to:
**http://127.0.0.1:8000/**
You should see the default Django welcome page!
---
## **Next Steps:**
**How to Create a Django App and Models** → [Watch Now]
**How to Use Django with MySQL** → [Watch Now]
**Deploy Django App on AWS EC2** → [Watch Now]
---
### ** Like, Share & Subscribe!**
If this tutorial helped you, **LIKE**, **SHARE**, and **SUBSCRIBE** for more Django & VS Code tutorials!
Have questions? Drop them in the **comments** below!
---
### ** Hashtags:**
#Django #Python #VisualStudioCode #VSCode #DjangoSetup #DjangoTutorial #WebDevelopment #PythonDevelopment #LearnDjango #Coding