📒
Notes
Cloud ComputingData Science/AIGame Development
  • Home
  • Big O
  • Data Structures & Algorithms
    • Data Structures
      • Array
      • Stack
      • Queue
      • Linked List
      • Binary Tree
    • Algorithms
      • Searching
      • Sorting
      • Graphs
        • Searching
        • Minimum Spanning Tree
        • Shortest Path Algorithms
      • String Algorithms
  • Object Oriented Programming
  • Languages
    • HTML/CSS
      • CSS
    • C++
    • C#
      • Types
      • Keywords
        • Modifiers
          • Access Modifiers
        • Method Parameters
      • Operators and Expressions
      • Collections
      • Constructors
      • Delegates
      • Indexers
      • Concepts
      • Features
        • LINQ
          • Operators
          • Working with Data
          • Methods
          • Resources
        • Asynchronous Programming
        • Reflection
    • Dart
    • GraphQL
    • JavaScript
      • Variable and Parameter
      • Built-in objects
        • Array
        • Built-in Functions
      • Functions
      • Classes
      • Prototype
      • Libraries
        • jQuery
        • React
          • Components
          • State and Lifecycle
          • Hooks
            • useState
            • useEffect
          • Resources
      • Testing Framework
      • Web APIs
    • Kotlin
      • Basics
    • Python
      • Basics
      • Data Structures
      • Functions
      • Resources
        • Flask
    • SQL
      • Basics
      • Operators
      • JOINs
      • Aggregations
      • Subqueries
      • Views
      • Functions
        • Window Functions
      • Stored Procedures
      • Performance Tuning
      • Extras
    • Resources
  • 🌐Web Frameworks
    • Angular
      • Templates
      • Directives
        • Attribute Directives
        • Structural Directives
    • ASP.NET
      • Fundamentals
        • Dependency Injection
        • Middleware
        • Session & State Management
      • Web apps
        • MVC
          • Controllers
            • Filters
          • Models
            • Model Binding
            • Model Validation
          • Views
            • Tag Helpers
            • View Components
          • Features
        • Client-side development
      • Web APIs
        • Controller-based APIs
        • Minimal APIs
        • OpenAPI
        • Content Negotiation
      • SignalR
      • Host and Deploy
        • IIS
      • Security
    • Django
      • The Request/Response Cycle
    • Terminologies
      • Web Server
        • Internet Information Services
    • Resources
  • 📱App Frameworks
    • Introduction
      • Resources
    • Xamarin
      • Lifecycle
      • Custom Renderers & Effects
      • Behaviors
      • Triggers
      • Gestures
      • Commands
      • Dependency Service in XF
      • Libraries
      • Showcase
    • .NET MAUI
      • Controls
      • Navigation
      • Storage Options
  • Multi-Platform Frameworks
    • .NET
      • .NET Framework
        • ADO.NET
        • WCF
      • Fundamentals
        • Logging
        • Testing
      • Advanced
        • Asynchronous Programming
        • Parallel Programming
        • Threading
        • Memory Management
          • Garbage Collection
    • Flutter
  • Object-Relational Mappers
    • Entity Framework
      • Application Models
      • Configuration
      • Setting Up
      • Advanced
  • Databases
    • Introduction
      • DBMS Architecture
      • Normalization
      • Database Transaction Models
    • Relational Databases
      • Microsoft SQL Server
        • Basics
        • Functions
        • Stored Procedures
        • Error Handling
        • Log Shipping
        • Querying and Manipulating JSON data
        • Statements
        • Topics
        • Extras
    • Non-Relational Databases
      • MongoDB
      • Redis
        • Data Structures
        • Introduction
        • Managing Database
  • Tools
    • Version Control
      • Git
        • Setup and Config
        • Basics
          • Sharing and Updating Projects
        • Resources
      • Perforce Helix
    • GitHub
    • Powershell
  • Software Development
    • Software Development Life Cycle
    • Software Design Patterns
      • GoF Design Patterns
      • Architectural Patterns
        • MVC
        • MVVM
        • N-tier Architecture
        • Onion Architecture
        • Data Transfer Objects
      • CQRS
    • Software Design Principles
      • S.O.L.I.D. Priniciple
  • System Design
    • Topics
      • Load Balancing
  • Topics
    • JWT
    • Caching
      • Static vs Dynamic Caching
    • OSI model
      • HTTP
    • Glossary
    • API
      • SOAP
      • REST
    • Microservices
    • WebHooks
    • Practice
    • Operating Systems
      • Windows
    • Architecture
  • 🔖Bookmarks
  • 🔗Resources
Powered by GitBook
On this page
  • Model-View-Template
  • View
  • Function-based View
  • Class-based View
  • Generic class-based View
  • Deployment

Was this helpful?

  1. Web Frameworks

Django

Web Framework

PreviousSecurityNextThe Request/Response Cycle

Last updated 1 year ago

Was this helpful?

The Django framework adopts an MVT approach. The model is the data layer of the application. The view layer is responsible for processing the request and returning the response. The template is the presentation layer.

URL dispatcher is another crucial component of the Django architecture. The URL dispatcher is equivalent to Controller in the MVC architecture. The urls.py module in the Django project's package folder acts as the dispatcher.

It defines the URL patterns. Each URL pattern is mapped with a view function to be invoked when the client's request URL matches it.

The URL patterns defined in each app under the project are also included in it.

When the server receives a request in the form of a client URL, the dispatcher matches its pattern with the patterns available in the urls.py and routes the flow of the application toward its associated view.

Virtualenv will isolate your Python/Django setup on a per-project basis. This means that any changes you make to one website won't affect any others you're also developing.

Model-View-Template

MVT is like MVC, except the re is no Controller and the Django Server itself performs the controller functions.

In Django, View is a python function that takes a web request(HTTP GET/POST/DELETE/UPDATE) and applies the neccessary logic to generate a web response(STRING, JSON/XML, HTML,ERROR STATUS).

Django uses a template containing static HTML elements and special Python code to generate dynamic web pages.

Project Structure

  • manage.py is a command line interface used to interact with the django project

  • settings.py contains the settings and configurations for your django project.

  • urls.py contains the URL and routing definitions of your Django app.

View

Function-based View

Pros
Cons

Simple and easy to understand

Difficult to extend or reuse

Explicit Code

Handles requests using conditional statements

Mainly built for a specific functionality

may increade code complexity

Class-based View

Pros
Cons

Reusable and Extendible

Code is harder to read

Handles requests using class methods

Implicit code is hidden from developers

Leverage built-in generic class-based views

Generic class-based View

  • ListView: represents a list of objects

  • DetailView: represents the details of an object

  • FormView: represents a form for submitting data

  • Group of Date views: handles date-based data

Deployment

WSGI
ASGI

Web Server Gateway Interface

Asynchronous Server Gateway Interface

Web Servers (Gunicorn, uWSGI, Apache, mod_wsgi)

Web Servers (Daphne, Hypercorn, Uvicorn)

🌐
LogoThe web framework for perfectionists with deadlines | Django
Logo30+ Django Interview Questions (2023) - InterviewBitInterviewBit