🐍 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! 🐍✨

Similar Posts