Django Tutorial, Django 3
Django is a free and open-source framework based on python programming language to develop web applications. The architecture of Django is Model-Template-View (MTV). The model layer relates to the logical database structure. The view layer is for data formatting and the template layer is the presentation layer.
This tutorial series shows you how to use Django to create a simple web application. The following image shows the application that we will create.
Topics to be covered
We will cover the following topics in this course
- How Django Works
- Django Features and Benefits
- Lessons to be covered
For you to successfully complete this course, you must meet the following requirements
- Relational Databases (SQL) - Although Django supports NoSQL Databases, most of the time a relational database is enough. The tutorial uses MySQL and SQLite. Thanks to Django ORM, we do not need to write complex SQL queries. However, you need to know how relational databases work
- Familiarity with how the internet works
- You need to know how the web works. A little about different HTTP methods, how requests are handled.
- Python Programming Basics - Django is based on python. Most of your coding in Django will be in python. So, if you have not learned python yet, you can start here
How Django Works
The architecture of Django is Model-Template-View (MTV). The MTV architectures separate the application into three layers:
- Model - has the logical structure of the database. Every operation that needs to get data from Database or add data to it, is handled by model. Since Django has a high-level ORM, you won't need to write SQL code to create or change your database.
- View - is the data formatting layer. Views handle the HTTP requests and return HTTP responses.
- Template - is the presentations layer. Any data that will be displayed to the client (HTML, CSS, JS), will be handled by templates also any data that is got by the user (Form inputs, etc.).
We will explain it by an example:
Imagine we have a book-keeping application. The user clicks on a button "BOOKS". What happens?
The user is redirected to
/books. Url Django detects this address and gives the request to the View layer. View layer checks if the user has the permission to this page or not, then asks ORM to get all books. The ORM runs a SQL query in the database and returns the results as a list of objects to View.
Then View passes the list of books to the template. The template creates an HTML (+ CSS and JS) page and returns it to the user's client. The user's client (web browser) renders HTML and presents a list of the books.
Django Features and Benefits
Django is a rich tool framework, so everything you need to develop a web application is provided. Starting a new project is easy and development is fast. When the application becomes bigger and the population of users grows, Django would be scalable.
Some successful applications Like Instagram, Disqus and bitbucket are using Django. Since Django is coded in python, you can use lots of python libraries in your application by adding them using the pip package manager.
In other word Django is
- Easy to start and develop the application
- Highly Scalable
- Ability to use python modules
- Trusted by big companies like Instagram, bitbucket and Disqus
Lessons to be covered
Some of the lessons that we will cover in this course include
- Django Development Environment
- Django Hello World
- Django Models
- Django Admin Interface
- Django Templates
- Django Views
- Django Authentication
- Django Form Processing
- Django AJAX Tutorial
- Django REST API
- Django VueJS
In this tutorial we have been briefly introduced to Django. We have discussed Django features and how it works based on the MTV architecture. We have met the Models, Views and Templates. Also, we have read the prerequisites to start developing a web application based on Django.
We will set up our environment, install software requirements and start a new simple web application project based on Django.
In the next lesson, we will look at how you can create a development environment for developing Django applications.