Setting up Django Project with virtual Environment

Search for a command to run...

No comments yet. Be the first to comment.
This is must-know Django stuff 👍Let’s walk through media files in Django clearly, from setup → usage → best practices. 1️⃣ What are media files? Media files are user-uploaded files, like: Profile photos Blog featured images PDFs, documents, etc....
Perfect timing to review this before Django 👍Django is very class-heavy, so getting this clear will make everything feel easier. What is a Class in Python? A class is a blueprint (template) to create objects. Think: Class → Design of a house 🏠 O...
🔹 1. What is a Function in Python? A function is a reusable block of code that performs a specific task. Instead of writing the same code again and again, you define once, use many times. Why functions? Reduce code repetition Improve readability ...

Introduction The DHT11 is a low-cost digital sensor used to measure temperature and humidity. It is widely used in electronics, IoT, weather monitoring systems, smart homes, and automation projects be
I’ll walk you through Django + virtual environment on Linux and Windows, step-by-step, clean and beginner-safe.
Make sure Python is installed:
python --version
or
python3 --version
If it prints Python 3.x.x, you’re good.
mkdir django_project
cd django_project
This folder will hold:
virtual environment
Django project code
python -m venv env
env\Scripts\activate
env\Scripts\Activate.ps1
If PowerShell blocks it, run once as admin:
Set-ExecutionPolicy RemoteSigned
Then activate again.
You’ll see:
(env) C:\django_project>
python -m pip install --upgrade pip
pip install django
Check:
django-admin --version
django-admin startproject mysite .
mysite . will create the project in current folder/directory as . represent current directorydjango-admin startproject mysite
cd mysite
python manage.py runserver
Open browser 👉
👉 http://127.0.0.1:8000/
deactivate
python3 -m venv env
This creates a folder called env.
source env/bin/activate
You’ll see something like:
(env) user@machine:~/django_project$
👉 This means virtual env is active
pip install --upgrade pip
pip install django
Verify:
django-admin --version
django-admin startproject mysite
cd mysite
Folder structure:
django_project/
├── venv/
└── mysite/
├── manage.py
└── mysite/
python manage.py runserver
Open browser 👉
👉 http://127.0.0.1:8000/
🎉 Django welcome page = SUCCESS
deactivate
🔥 Common Mistakes (Important)
❌ Forgetting to activate venv
❌ Installing Django globally
❌ Running runserver outside project folder
❌ Using python vs python3 incorrectly on Linux
Managing Dependency using pip freeze
pip freeze will output the list of packages with versions installed in the current virtual environment (if activated)

We can then save that list to a file named requirements.txt for future ( so we can reinstall everything in new setup environment)
pip freeze > requirements.txt
This will make a file named requirements.txt and save the output of pip freeze that has packages and its versions
Later you can install everything with:
pip install -r requirements.txt