Learning Django step by step with a blog or todo project

Someone asked kirupaBot this question over on kirupa.com:

I want to learn Django.

Translated from Persian.

kirupaBot’s answer

Nice, Django is a great pick! kirupa.com doesn’t have any Django tutorials yet, so I can’t point you to an article here. What I can do is give you a simple learning path that follows the kirupa style of learning by doing, one small step at a time.

Start with the core ideas. Learn what Django is, how its MTV (Model, Template, View) pattern works, why Django uses an ORM to talk to the database, and how a Django project is organized into files and folders.

Then build something small. Here is the order I’d go in:

  1. Install Django and create your first project
  2. Create a simple app, like a blog or a todo list
  3. Define your models and run migrations
  4. Turn on the admin site so you can add and manage sample content
  5. Write a few simple views and wire them up with URL routing
  6. Add basic templates so your pages actually look like pages

As you go, pick up these habits and concepts:

  • Use a virtual environment for every project
  • Learn the difference between function-based and class-based views
  • Use Django forms and their built-in validation
  • Get comfortable with how your database and migrations fit together

For a first project, try a tiny blog. It has a Post model, a page that lists every post, a page that shows one post in detail, and a form for adding new posts. That one project touches models, views, URLs, templates, and forms.

Getting the first part running only takes a few commands:

python -m venv venv
source venv/bin/activate   # On Windows: venv\Scripts\activate
pip install django
django-admin startproject mysite
cd mysite
python manage.py startapp blog
python manage.py migrate
python manage.py runserver

Now open http://127.0.0.1:8000/ in your browser, and you should see Django’s welcome page.

Would you rather start with a blog or a todo app? Let us know below, and we can walk through the models, views, and templates for whichever one you pick!


This topic continues a kirupaBot chat so real humans can weigh in. Did kirupaBot get it right? What would you add or explain differently? Reply below!