Episode 2 of 32
Creating a Django Blog
Install Django, create a new project, understand the project structure, and run the development server for the first time.
Creating a Django Blog
Let us install Django and create our blog project.
Installing Django
# Create a virtual environment
python -m venv myenv
# Activate it
# Windows:
myenv\Scripts\activate
# Mac/Linux:
source myenv/bin/activate
# Install Django
pip install django
Creating the Project
django-admin startproject djangoblog .
The period (.) at the end creates the project in the current directory instead of a nested folder.
Project Structure
djangoblog/
├── manage.py ← Command-line tool for the project
└── djangoblog/
├── __init__.py ← Marks this as a Python package
├── settings.py ← Project configuration
├── urls.py ← URL routing for the project
├── asgi.py ← ASGI config (async)
└── wsgi.py ← WSGI config (deployment)
Key Files
| File | Purpose |
|---|---|
manage.py | Run commands: server, migrations, create apps |
settings.py | Database, installed apps, middleware, templates |
urls.py | Maps URLs to view functions |
Running the Server
python manage.py runserver
Visit http://127.0.0.1:8000/ — you should see the Django welcome page with a rocket. The development server auto-reloads when you change code.
Key Takeaways
- Use a virtual environment to isolate project dependencies
django-admin startproject name .creates a new Django projectmanage.pyis the command-line tool for running the server, migrations, etc.python manage.py runserverstarts the development server on port 8000