Getting Started with Django: A Simple Tutorial for Beginners
If you’re looking to build web applications with Python, Django is one of the best frameworks to start with. It’s fast, secure, and comes with a lot of built-in features. In this beginner-friendly tutorial, we’ll walk through creating a simple Django app — a To-Do List.
What You’ll Need
Before we start, make sure you have the following installed:
-
Python 3.x
-
pip (Python package installer)
-
Virtualenv (optional but recommended)
Step 1: Set Up Your Project
Open your terminal and follow these steps:
# Create a project directorymkdir mytodocd mytodo
# Create a virtual environmentpython -m venv venvsource venv/bin/activate # On Windows: venv\Scripts\activate
# Install Djangopip install django
# Create a new Django projectdjango-admin startproject todo_project .
Run the server to test
python manage.py runserver
Open http://127.0.0.1:8000 — you should see the Django welcome page.
Step 2: Create the To-Do App
Now let’s create a Django app inside our project.
python manage.py startapp todo
Add 'todo' to your INSTALLED_APPS in todo_project/settings.py:
INSTALLED_APPS = [ ... 'todo',]
Step 3: Define the To-Do Model
In todo/models.py:
from django.db import models
class Task(models.Model): title = models.CharField(max_length=200) completed = models.BooleanField(default=False)
def __str__(self): return self.title
Then run:
python manage.py makemigrationspython manage.py migrate
Step 4: Create a Simple Admin Interface
In todo/admin.py:
from django.contrib import adminfrom .models import Task
admin.site.register(Task)
Create a superuser to access the admin:
python manage.py createsuperuser
Visit http://127.0.0.1:8000/admin and log in — you’ll see the Task model.
Step 5: Create Views and Templates
In todo/views.py:
from django.shortcuts import renderfrom .models import Task
def home(request): tasks = Task.objects.all() return render(request, 'todo/home.html', {'tasks': tasks})
Create a folder todo/templates/todo/ and add home.html:
<!DOCTYPE html><html><head> <title>To-Do List</title></head><body> <h1>My To-Do List</h1> <ul> {% for task in tasks %} <li> {{ task.title }} - {% if task.completed %}✔{% else %}✖{% endif %} </li> {% endfor %} </ul></body></html>
Step 6: Set Up URLs
In todo/urls.py (create it if it doesn't exist):
from django.urls import pathfrom . import views
urlpatterns = [ path('', views.home, name='home'),]
Then in todo_project/urls.py, include the app's URLs:
from django.contrib import adminfrom django.urls import path, include
urlpatterns = [ path('admin/', admin.site.urls), path('', include('todo.urls')),]
You’re Done!
Now run your server again:
python manage.py runserver
Visit http://127.0.0.1:8000 — you’ll see your To-Do list in action!
Final Thoughts
You’ve just created a simple Django app with:
-
A database model
-
Admin interface
-
Views and templates
-
URL routing
From here, you can add features like form submission, user authentication, and styling with Bootstrap or Tailwind CSS.
🧠 Want more tutorials like this? Let me know in the comments, or suggest your next project idea!
Tags:
Comments
Leave a Comment
Blog List

Great job you are doing here, how can I learn from you?