Python

Django Tutorial for Beginners 2026 — Build Your First Web App in Python

Django is the most popular Python web framework — used by Instagram, Pinterest, NASA, and thousands of startups worldwide. This beginner tutorial walks you through building a complete web application from scratch, covering Django's MVT architecture, database models, views, templates, admin panel, and deployment.

By Rajan Verma
16 min read

Django is Python's most powerful and battle-tested web framework. Used by Instagram (before rewriting some parts in custom solutions), Pinterest, Disqus, and thousands of high-growth startups, Django follows the "batteries included" philosophy — it provides everything you need to build a secure, scalable web application without stitching together dozens of third-party packages. This tutorial gives you a complete, practical foundation for building and deploying your first Django web application in 2026.

Prerequisites: Before starting this tutorial, make sure you are comfortable with Python fundamentals — particularly functions, classes, and dictionaries. If you are new to Python entirely, spend 4–6 weeks on Python basics first. Our Python Automation beginner guide is a good starting point.
75,000+
Django packages on PyPI
₹4–35 LPA
Django developer salary in India
8–12 wks
To build first functional Django app
#1
Python web framework by job demand India

What Is Django and Why Use It?

Django is an open-source, high-level Python web framework that was created in 2003 by Adrian Holovaty and Simon Willison at a newspaper company (the Lawrence Journal-World in Kansas). It was designed to help journalists build information-rich web applications fast. That history is instructive: Django was built for speed of development, practical functionality, and handling real-world complexity — not academic elegance.

Django's key advantages over building a web app from scratch or using minimal frameworks: a built-in ORM (Object-Relational Mapper) that lets you define your database structure in Python rather than SQL; an automatically generated admin interface for managing your data without writing any admin code; a robust authentication system (login, logout, passwords, permissions) out of the box; strong security defaults (CSRF protection, SQL injection prevention, XSS protection); and Django REST Framework (DRF) for building APIs.

Understanding Django's MVT Architecture

Django uses the Model-View-Template (MVT) pattern — a variation of the classic MVC (Model-View-Controller) architecture. Understanding this is the first fundamental step:

Model: Represents your data structure. Django models are Python classes that define database tables and the relationships between them. Each attribute in your model class becomes a column in your database table. The ORM handles all the SQL — you never write raw SQL (though you can when needed).

View: Contains the business logic. A Django view receives an HTTP request and returns an HTTP response. Views retrieve data from models, perform calculations, and pass data to templates. Django supports function-based views (FBVs) — simple Python functions — and class-based views (CBVs) — Python classes with predefined behaviour for common patterns like list display, detail pages, and forms.

Template: The presentation layer. Django templates are HTML files with Django Template Language (DTL) tags that allow you to display dynamic data, loop over lists, show/hide content based on conditions, and inherit from base templates for consistent design.

The complete request cycle: User opens URL → Django's URL router matches it → Calls the corresponding View → View queries the Model → Model returns data → View passes data to Template → Template renders HTML → Django sends HTML to user's browser.

Setting Up Your Development Environment

1
Install Python 3.11+ from python.org. Confirm installation by running python --version in your terminal. You should see Python 3.11.x or higher.
2
Create a Virtual Environment: Run python -m venv myenv in your project folder. A virtual environment isolates your project's dependencies from your global Python installation. Always use virtual environments for Django projects.
3
Activate the Virtual Environment: On Windows: myenv\Scripts\activate. On Mac/Linux: source myenv/bin/activate. You'll see (myenv) prefix in your terminal when active.
4
Install Django: Run pip install django. Verify with python -m django --version. As of 2026, Django 5.x is the stable release.
5
Create Your Django Project: Run django-admin startproject myproject. This creates the project folder structure with settings.py, urls.py, wsgi.py, and asgi.py.
6
Run the Development Server: Navigate into the project folder (cd myproject) and run python manage.py runserver. Visit http://127.0.0.1:8000 — you should see Django's welcome page.

Models and the ORM — Defining Your Data

Django models are where you define your application's data structure. Each model becomes a database table. You define model fields using Django's built-in field types: CharField for short text, TextField for long text, IntegerField for numbers, DateField and DateTimeField for dates, BooleanField for true/false, ForeignKey for relationships between tables, and ManyToManyField for many-to-many relationships.

After defining models, you create migrations — Python files that describe the database changes. Run python manage.py makemigrations to create migration files, then python manage.py migrate to apply them to the database. This is how Django tracks and applies schema changes without requiring you to write SQL ALTER TABLE commands manually.

The ORM lets you query the database using Python methods instead of SQL. Common query patterns: ModelName.objects.all() retrieves every record; ModelName.objects.filter(field=value) filters records; ModelName.objects.get(pk=1) retrieves a single record by primary key; .exclude(), .order_by(), .values(), and .annotate() add further power. Django's ORM generates optimised SQL behind the scenes, and you can inspect the actual SQL with query attribute on any queryset.

Views, URL Routing, and Templates

Function-based views are the simplest way to start. A view function takes an HttpRequest object and returns an HttpResponse. For most common use cases, Django provides Generic Class-Based Views (ListView, DetailView, CreateView, UpdateView, DeleteView) that handle the boilerplate for standard CRUD operations, requiring you to specify only the model and template name.

URL routing in Django maps URL patterns to view functions or classes. The main urls.py in your project routes to app-level urls.py files using the include() function, keeping URL definitions organised by application. URL patterns use path() for exact matches and re_path() for regex patterns. Named URLs (using the name parameter) let you reference URLs by name in templates rather than hardcoding paths — this is best practice from day one.

Django templates support variable output with {{ variable }}, template tags with {% tag %} for logic and control flow, template filters with {{ value|filter }} for formatting, and template inheritance with {% extends "base.html" %} and {% block content %}. Template inheritance is one of Django's most powerful features — define your navigation, footer, and head section once in base.html and inherit them across every page.

Django Admin — Your Free Back-Office

One of Django's most celebrated features is the automatic admin interface. Register your models in admin.py with admin.site.register(ModelName), create a superuser with python manage.py createsuperuser, and visit /admin. You get a fully functional CRUD interface for all your registered models — completely customisable.

You can customise the admin by subclassing ModelAdmin: define list_display to control which columns appear in the list view, search_fields to add a search box, list_filter for sidebar filtering, ordering for default sort order, and fieldsets for grouping fields on the detail page. The admin is so capable that many Django applications ship with the admin as their entire back-office, replacing purpose-built admin tools that would take weeks to develop.

User Authentication and Forms

Django ships with a complete authentication system including user registration, login, logout, password reset via email, and permissions/groups. The django.contrib.auth application handles all of this. Use Django's built-in LoginView and LogoutView for standard auth flows, and UserCreationForm for registration pages.

Django forms are Python classes that define form fields, handle validation, and process submitted data. Forms can be built from scratch or generated from models using ModelForm — which automatically creates form fields from your model's field definitions. Form validation, CSRF protection, and error display are all handled by the framework.

Deploying to PythonAnywhere

PythonAnywhere is the easiest free deployment option for Django beginners. The process: create a free PythonAnywhere account, upload your code (via Git is recommended), create a virtual environment and install requirements.txt, configure the WSGI file to point to your Django application, set up a MySQL database (free on PythonAnywhere's basic plan), configure your static files collection with python manage.py collectstatic, and reload the web app. Your site goes live at yourusername.pythonanywhere.com.

Django vs Flask vs FastAPI — Career Comparison

FeatureDjangoFlaskFastAPI
Built-in AdminYes (exceptional)NoNo
Built-in ORMYesNoNo (use SQLAlchemy)
Built-in AuthYesNoNo
Learning CurveSteep initiallyGentleMedium
API PerformanceGoodGoodExcellent
Job Demand IndiaHighestMediumGrowing rapidly
Best ForFull web appsMicroservices/APIsHigh-performance APIs
Avg. Salary India₹6–20 LPA₹5–18 LPA₹8–25 LPA

Ready to build your first Django web application with expert guidance? UnstopGrowth's Python & Django course in Chandigarh includes 3 full project builds, deployment training, and placement support. Book your free demo class →

Key Takeaway: Django remains the most practical Python web framework for beginners targeting web development careers in India. Its "batteries included" approach means you learn production-quality patterns from day one — authentication, admin panels, ORM queries, form handling, and deployment. The time investment (8–12 weeks to build a functional application) is among the best in software development. A Django developer with 2–3 years of experience in India earns ₹8–15 LPA, with senior roles reaching ₹30+ LPA at product companies.
Django 2026 Python Web Development Django Tutorial Django vs Flask MVT Architecture Django Admin Deploy Django Django Developer Salary

Frequently Asked Questions

Yes. You should be comfortable with Python fundamentals — variables, data types, functions, classes (OOP basics), and file handling — before starting Django. Django is a Python framework, and you will struggle to understand why things work the way they do without a solid Python base. Spend at least 4–6 weeks on Python first.
With consistent practice, a Python beginner can build a functional Django application in 8–12 weeks. Reaching production-level proficiency (proper authentication, REST APIs, deployment, security hardening) typically takes 4–6 months. If you already know Python well, basic Django can be learned in 3–4 weeks.
It depends on your project. Django is best for full-featured web applications that need an admin panel, ORM, authentication, and many built-in components. Flask is better for minimalist applications where you want fine-grained control. FastAPI is best for building fast REST APIs and is increasingly popular for microservices. For beginners building web apps, Django is the most practical choice.
A fresher Django developer in India earns ₹4–6 LPA. With 2–3 years of experience (Django + REST APIs + basic deployment), salary rises to ₹8–15 LPA. Senior Django/Python developers at product companies earn ₹18–35 LPA. Adding React or Vue skills for full-stack capability further increases salary by 20–40%.
Yes. PythonAnywhere offers a free tier that is perfect for learning and small personal projects. Railway.app provides 500 hours of free compute monthly. Render.com has a free tier for web services. For production applications with real traffic, a DigitalOcean Droplet (₹600/month) or AWS EC2 t3.micro is more reliable.
Rajan Verma
Senior Python Instructor & Web Developer | UnstopGrowth

Rajan Verma has built and deployed 50+ Django web applications over 15 years. He teaches Python and Django to students in Chandigarh at UnstopGrowth, focusing on practical, production-quality web development skills that translate directly to employment.

Learn Django with Real Projects — Chandigarh & Online

UnstopGrowth's Python & Django course covers everything from fundamentals to deployment. Build 3 full Django projects with mentor guidance. Free demo available.