π Setting Up a Python & Django Dev Environment (Beginner Friendly)
π Setting Up a Python & Django Dev Environment (Beginner Friendly)
So you want to dive into Django, the Python web framework that powers sites like Instagram, Pinterest, and even NASA tools? π
You’re in the right place! Letβs walk step-by-step through setting up a Django development environment β the right way, with zero fluff.
π§° What Youβll Need
β A computer
β Internet
β Some basic Python knowledge
β A sense of humor (debugging helps)
π§ Step 1: Install Python π
If you donβt already have Python:
π Go to https://python.org/downloads and install Python 3.10+
β Check installation:
python --version
# or sometimes
python3 --version
π¦ Step 2: Set Up a Virtual Environment
Virtual environments keep your projects isolated. No mess, no mix-ups.
# Create a folder for your project
mkdir my_django_project
cd my_django_project
# Create a virtual environment
python -m venv venv
# Activate it
# On Windows:
venvScriptsactivate
# On Mac/Linux:
source venv/bin/activate
β
You should now see (venv)
in your terminal.
π Step 3: Install Django
Letβs install Django into your virtual environment:
pip install django
β Confirm it:
django-admin --version
ποΈ Step 4: Start a New Django Project
django-admin startproject config .
Yes, that .
at the end keeps the folder clean (no nested config/config
madness).
π οΈ Step 5: Run the Development Server
python manage.py runserver
Then open:
http://127.0.0.1:8000/
π You should see Djangoβs βIt worked!β screen.
π§ͺ Step 6: Create an App
In Django, projects are made of apps.
python manage.py startapp core
Then add 'core',
to INSTALLED_APPS
in config/settings.py
.
π Bonus: Install Dev Tools
pip install black isort django-debug-toolbar
Want cool admin themes?
pip install django-admin-interface
π§Ύ Example requirements.txt
Django>=4.0
black
isort
django-debug-toolbar
django-admin-interface
You can save this and run:
pip install -r requirements.txt
π Editor Setup
Use VS Code (or any Python-supporting editor).
- Install the Python extension
- Enable “Format on Save” using Black
- Install the Django extension (for model navigation and templates)
π Suggested Folder Structure
my_django_project/
βββ config/
β βββ __init__.py
β βββ settings.py
β βββ urls.py
β βββ wsgi.py
βββ core/
β βββ models.py
β βββ views.py
β βββ ...
βββ manage.py
βββ venv/
βββ requirements.txt
π€ Common Errors
β django-admin: command not found
β‘οΈ Make sure your virtual environment is activated
β ModuleNotFoundError: No module named 'Django'
β‘οΈ Install Django inside the virtual environment
β AllowedHosts error
β‘οΈ Set ALLOWED_HOSTS = ['*']
in dev (but donβt do this in prod!)
π§ Final Thoughts
Django is powerful, elegant, and incredibly beginner-friendly β but the setup must be clean. Using virtual environments and knowing your tools helps avoid dev pain later.
βGive me six hours to set up a Django project and I will save weeks of debugging.β
β Not Abraham Lincoln, but close
π¨ TL;DR
Step | Command or Action |
---|---|
1οΈβ£ | Install Python 3.10+ |
2οΈβ£ | python -m venv venv |
3οΈβ£ | pip install django |
4οΈβ£ | django-admin startproject config . |
5οΈβ£ | python manage.py runserver |
6οΈβ£ | Create apps, install tools, and start building! |
π‘ What Next?
- Learn Django Models, Views, and Templates
- Try building a blog app
- Use
sqlite3
first, then level up to PostgreSQL - Deploy your app to Render or Vercel
Good luck, future Django developer! πβ¨