Experiment 11
Aim: To implement an application using the Python Django Web Framework.
Learning Objectives
• Learn the basics of Django.
• Understand how to create and manage a Django application.
Theory:
Django is a high-level Python web framework that encourages rapid development and clean,
pragmatic design. It includes many built-in features like an ORM, authentication, and an
admin interface.
Django follows the MVT design pattern (Model View Template).
• Model - The data you want to present, usually data from a database.
• View - A request handler that returns the relevant template and content - based on the
request from the user.
• Template - A text file (like an HTML file) containing the layout of the web page, with logic on
how to display the data.
Model
The model provides data from the database.
In Django, the data is delivered as an Object Relational Mapping (ORM), which is a technique
designed to make it easier to work with databases.
Django, with ORM, makes it easier to communicate with the database, without having to write
complex SQL statements.
The models are usually located in a file called [Link].
View
A view is a function or method that takes http requests as arguments, imports the relevant
model(s), and finds out what data to send to the template, and returns the final result.
The views are usually located in a file called [Link].
Template
A template is a file where you describe how the result should be represented.
Templates are often .html files, with HTML code describing the layout of a web page, but it can
also be in other file formats to present other results, but we will concentrate on .html files.
There is a [Link] in your members folder that looks like this:
my_tennis_club/members/[Link]:
In the browser window, type [Link]:8000/members/ in the address bar