SlideShare a Scribd company logo
1 of 7
MODEL-VIEW-CONTROLLER
(MVC) PATTERN IN DJANGO
www.studysection.com
INTRODUCTION
Django uses the Model-View-Controller (MVC) pattern, with slight variations,
primarily following the Model-Template-View (MTV) pattern. This structure
enhances developer productivity and maintainability. Models represent the
data layer, View handles presentation logic, and Controller coordinates
interactions. MTV maintains data-related tasks, while Views serve as
Controllers, promoting maintainable code and modularity in Django web
applications. the data layer, View handles presentation logic, and Controller
coordinates interactions. MTV maintains data-related tasks, while Views
serve as Controllers, promoting maintainable code and modularity in Django
web applications.
DJANGO ARCHITECTURE
COMPONENTS
• Django's Model is the data layer, encapsulating application
structure, ensuring integrity, and handling database interaction,
defined as Python classes inheriting from
django.db.models.Model.
• Django's Views are Python functions that handle incoming
requests, data retrieval, and rendering, encapsulating application
logic and handling business logic, determining data display and
user response.
• Django templates, like the View component in MVC, generate the
application's presentation layer, containing HTML markup,
embedded tags, and filters, dynamically rendering data and
sending output to the client's web browser.
Simplified example of a
Django model
from django.db import models
class Post(models.Model):
title =models.CharField(max_length=100)
content = models.TextField()
created_at =
models.DateTimeField(auto_now_add=True)
Example of a Django View
Function: from django.http
import HttpResponse def hello(request):
return HttpResponse("Hello, Django!")
from django.shortcuts import render
from .models import Product
Example of a Django
Template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-
scale=1.0">
<title>My Template</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
TO READ MORE ON THIS TOPIC
Do visit: https://studysection.com/blog
www.studysection.com

More Related Content

Similar to Model-View-Controller (MVC) Pattern in Django

Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoKnoldus Inc.
 
Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django frameworkKnoldus Inc.
 
Mcv design patterns
Mcv design patternsMcv design patterns
Mcv design patternsRob Paok
 
Single page application 03
Single page application   03Single page application   03
Single page application 03Ismaeel Enjreny
 
OOAD_CH_04_mvc-architecture.pdf
OOAD_CH_04_mvc-architecture.pdfOOAD_CH_04_mvc-architecture.pdf
OOAD_CH_04_mvc-architecture.pdfZahidAkon2
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworksMukesh Kumar
 
Unleash-the-power-of-Django.pptx
Unleash-the-power-of-Django.pptxUnleash-the-power-of-Django.pptx
Unleash-the-power-of-Django.pptxShivamSv1
 
Workshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCWorkshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCVisual Engineering
 
Pattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecturePattern oriented architecture for web based architecture
Pattern oriented architecture for web based architectureshuchi tripathi
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptxSafnaSaff1
 
Django Frequently Asked Interview Questions
Django Frequently Asked Interview QuestionsDjango Frequently Asked Interview Questions
Django Frequently Asked Interview QuestionsAshishMishra308598
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patternsallanh0526
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: AndroidJitendra Kumar
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoAhmed Salama
 

Similar to Model-View-Controller (MVC) Pattern in Django (20)

Angular introduction basic
Angular introduction basicAngular introduction basic
Angular introduction basic
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django framework
 
Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
 
Django framework
Django frameworkDjango framework
Django framework
 
Mcv design patterns
Mcv design patternsMcv design patterns
Mcv design patterns
 
Single page application 03
Single page application   03Single page application   03
Single page application 03
 
MVC in PHP
MVC in PHPMVC in PHP
MVC in PHP
 
OOAD_CH_04_mvc-architecture.pdf
OOAD_CH_04_mvc-architecture.pdfOOAD_CH_04_mvc-architecture.pdf
OOAD_CH_04_mvc-architecture.pdf
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
 
Unleash-the-power-of-Django.pptx
Unleash-the-power-of-Django.pptxUnleash-the-power-of-Django.pptx
Unleash-the-power-of-Django.pptx
 
MVC & backbone.js
MVC & backbone.jsMVC & backbone.js
MVC & backbone.js
 
Workshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCWorkshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVC
 
Pattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecturePattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecture
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptx
 
Django Frequently Asked Interview Questions
Django Frequently Asked Interview QuestionsDjango Frequently Asked Interview Questions
Django Frequently Asked Interview Questions
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js Tutorials
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 

More from StudySection

Understanding Requirements Traceability Matrix (RTM).pdf
Understanding Requirements Traceability Matrix (RTM).pdfUnderstanding Requirements Traceability Matrix (RTM).pdf
Understanding Requirements Traceability Matrix (RTM).pdfStudySection
 
Laravel Eloquent: Empowering Database Interactions with Elegance
Laravel Eloquent: Empowering Database Interactions with EleganceLaravel Eloquent: Empowering Database Interactions with Elegance
Laravel Eloquent: Empowering Database Interactions with EleganceStudySection
 
Comparison of Function Components and Class Components in React.js
Comparison of Function Components and Class Components in React.jsComparison of Function Components and Class Components in React.js
Comparison of Function Components and Class Components in React.jsStudySection
 
Explore The Effective Caching Strategies
Explore The Effective Caching StrategiesExplore The Effective Caching Strategies
Explore The Effective Caching StrategiesStudySection
 
What is a microservices architecture in Laravel?
What is a microservices architecture in Laravel?What is a microservices architecture in Laravel?
What is a microservices architecture in Laravel?StudySection
 
Unveiling the PHP Application Controller Paradigm
Unveiling the PHP Application Controller ParadigmUnveiling the PHP Application Controller Paradigm
Unveiling the PHP Application Controller ParadigmStudySection
 
Unveil the Power of Socket.IO in Node.js
Unveil the Power of Socket.IO in Node.jsUnveil the Power of Socket.IO in Node.js
Unveil the Power of Socket.IO in Node.jsStudySection
 
Software Process Improvement and Capability Determination (SPICE)
Software Process Improvement and Capability Determination (SPICE)Software Process Improvement and Capability Determination (SPICE)
Software Process Improvement and Capability Determination (SPICE)StudySection
 
Software Process Improvement and Capability Determination.pdf
Software Process Improvement and Capability Determination.pdfSoftware Process Improvement and Capability Determination.pdf
Software Process Improvement and Capability Determination.pdfStudySection
 
Explain the Two-Step View pattern with an example in PHP.docx
Explain the Two-Step View pattern with an example in PHP.docxExplain the Two-Step View pattern with an example in PHP.docx
Explain the Two-Step View pattern with an example in PHP.docxStudySection
 
The Imperatives of Cross-Browser Testing
The Imperatives of Cross-Browser TestingThe Imperatives of Cross-Browser Testing
The Imperatives of Cross-Browser TestingStudySection
 
Implementation of the Data Mapper Pattern in Python.docx
Implementation of the Data Mapper Pattern in Python.docxImplementation of the Data Mapper Pattern in Python.docx
Implementation of the Data Mapper Pattern in Python.docxStudySection
 
JavaScript Overview_ Features, History, Advantages, and Limitations.docx
JavaScript Overview_ Features, History, Advantages, and Limitations.docxJavaScript Overview_ Features, History, Advantages, and Limitations.docx
JavaScript Overview_ Features, History, Advantages, and Limitations.docxStudySection
 

More from StudySection (13)

Understanding Requirements Traceability Matrix (RTM).pdf
Understanding Requirements Traceability Matrix (RTM).pdfUnderstanding Requirements Traceability Matrix (RTM).pdf
Understanding Requirements Traceability Matrix (RTM).pdf
 
Laravel Eloquent: Empowering Database Interactions with Elegance
Laravel Eloquent: Empowering Database Interactions with EleganceLaravel Eloquent: Empowering Database Interactions with Elegance
Laravel Eloquent: Empowering Database Interactions with Elegance
 
Comparison of Function Components and Class Components in React.js
Comparison of Function Components and Class Components in React.jsComparison of Function Components and Class Components in React.js
Comparison of Function Components and Class Components in React.js
 
Explore The Effective Caching Strategies
Explore The Effective Caching StrategiesExplore The Effective Caching Strategies
Explore The Effective Caching Strategies
 
What is a microservices architecture in Laravel?
What is a microservices architecture in Laravel?What is a microservices architecture in Laravel?
What is a microservices architecture in Laravel?
 
Unveiling the PHP Application Controller Paradigm
Unveiling the PHP Application Controller ParadigmUnveiling the PHP Application Controller Paradigm
Unveiling the PHP Application Controller Paradigm
 
Unveil the Power of Socket.IO in Node.js
Unveil the Power of Socket.IO in Node.jsUnveil the Power of Socket.IO in Node.js
Unveil the Power of Socket.IO in Node.js
 
Software Process Improvement and Capability Determination (SPICE)
Software Process Improvement and Capability Determination (SPICE)Software Process Improvement and Capability Determination (SPICE)
Software Process Improvement and Capability Determination (SPICE)
 
Software Process Improvement and Capability Determination.pdf
Software Process Improvement and Capability Determination.pdfSoftware Process Improvement and Capability Determination.pdf
Software Process Improvement and Capability Determination.pdf
 
Explain the Two-Step View pattern with an example in PHP.docx
Explain the Two-Step View pattern with an example in PHP.docxExplain the Two-Step View pattern with an example in PHP.docx
Explain the Two-Step View pattern with an example in PHP.docx
 
The Imperatives of Cross-Browser Testing
The Imperatives of Cross-Browser TestingThe Imperatives of Cross-Browser Testing
The Imperatives of Cross-Browser Testing
 
Implementation of the Data Mapper Pattern in Python.docx
Implementation of the Data Mapper Pattern in Python.docxImplementation of the Data Mapper Pattern in Python.docx
Implementation of the Data Mapper Pattern in Python.docx
 
JavaScript Overview_ Features, History, Advantages, and Limitations.docx
JavaScript Overview_ Features, History, Advantages, and Limitations.docxJavaScript Overview_ Features, History, Advantages, and Limitations.docx
JavaScript Overview_ Features, History, Advantages, and Limitations.docx
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 

Model-View-Controller (MVC) Pattern in Django

  • 1. MODEL-VIEW-CONTROLLER (MVC) PATTERN IN DJANGO www.studysection.com
  • 2. INTRODUCTION Django uses the Model-View-Controller (MVC) pattern, with slight variations, primarily following the Model-Template-View (MTV) pattern. This structure enhances developer productivity and maintainability. Models represent the data layer, View handles presentation logic, and Controller coordinates interactions. MTV maintains data-related tasks, while Views serve as Controllers, promoting maintainable code and modularity in Django web applications. the data layer, View handles presentation logic, and Controller coordinates interactions. MTV maintains data-related tasks, while Views serve as Controllers, promoting maintainable code and modularity in Django web applications.
  • 3. DJANGO ARCHITECTURE COMPONENTS • Django's Model is the data layer, encapsulating application structure, ensuring integrity, and handling database interaction, defined as Python classes inheriting from django.db.models.Model. • Django's Views are Python functions that handle incoming requests, data retrieval, and rendering, encapsulating application logic and handling business logic, determining data display and user response. • Django templates, like the View component in MVC, generate the application's presentation layer, containing HTML markup, embedded tags, and filters, dynamically rendering data and sending output to the client's web browser.
  • 4. Simplified example of a Django model from django.db import models class Post(models.Model): title =models.CharField(max_length=100) content = models.TextField() created_at = models.DateTimeField(auto_now_add=True)
  • 5. Example of a Django View Function: from django.http import HttpResponse def hello(request): return HttpResponse("Hello, Django!") from django.shortcuts import render from .models import Product
  • 6. Example of a Django Template: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial- scale=1.0"> <title>My Template</title> </head> <body> <h1>Hello, World!</h1> </body> </html>
  • 7. TO READ MORE ON THIS TOPIC Do visit: https://studysection.com/blog www.studysection.com