Skip to content

Django

Web framework for Python.

Resources

Architecture

MVT

Not directly analogous to MVC pattern.

  • Model: mediator / interface between app and database
  • Template: defines static parts of web pages and how to insert and render dynamic parts
  • View: the interface between the client and the app. Handles requests and sending responses. Uses Models and Templates to generate responses. Somewhat like a controller in MVC

Apps

Technically, these are Python packages intended to be used with a Django project. Can be see as "components" of sorts within a Django project. Projects need at least one app. Apps should be created at same directory level as manage.py

Class-based views

Why use class-based views? Introduction to class-based views

  • Organize code for different HTTP methods (GET, POST, etc) with separate methods, instead of branching logic within a single function
  • Can use OOP techniques to make code into reusable components, e.g. mixins / multiple inheritance