Django BasicsCore· 30 min read

What is Django? (MVT)

A Python framework that gives you almost everything to build a website — fast and securely.

What you will learn

  • Understand what Django is
  • Learn the MVT pattern
  • See why Django saves time

Batteries included

Django is a Python web framework that comes with almost everything you need: URL routing, a database layer (an ORM — Object-Relational Mapper, a tool that lets you use the database with normal Python instead of writing SQL — Structured Query Language, the special text language databases normally use — by hand), a ready-made admin panel, user login, forms and security — all built in. You write less code and ship faster.

The MVT pattern

PartJob
ModelYour data (a Python class = a database table)
ViewThe logic (a Python function that handles a request)
TemplateThe HTML the user sees

The flow: a request hits a URL → Django calls a view → the view uses a model to get data → it passes that data to a template → the finished HTML is sent back.

A concrete walk-through. Imagine your blog has two posts saved: "Hello Django" and "My second post". A visitor opens the address /posts in their browser. Here is what each MVT part does:

  1. The visitor’s browser requests the URL /posts.
  2. Django matches that URL and runs the matching view (a Python function called, say, post_list).
  3. The view asks the Model for the data — "give me all posts" — and gets back the two saved posts.
  4. The view hands those two posts to a Template (an HTML file) that loops over them.
  5. The finished HTML — a page listing "Hello Django" and "My second post" — is sent back and shown in the browser.

Note: So with two posts in the database, the visitor ends up seeing a page that lists both titles. Each MVT part did one job: URL found the view, the view got the data from the model, and the template turned it into the page.

Tip: Everything you learned in Python — variables, functions, classes — is used here. Django models are just Python classes; views are just Python functions.

Q. In Django’s MVT, what holds your data (a database table)?

Answer: The Model is a Python class that maps to a database table. Views hold logic; Templates render HTML.

✍️ Practice

  1. Draw the Django request flow for “show a list of posts”.
  2. Match Model/View/Template to what each does.

🏠 Homework

  1. Explain MVT in your own words with a simple analogy.
Want to learn this with a mentor?

CodingClave runs guided, project-based training (28-day, 45-day & 6-month batches).

Explore Training →