Basics Of Django

Django is a Python web framework. Let's understand what is Django in detail.
 

The first and foremost question is, what is Django?

 
Django is a high-level Python Web framework. Your mother performs many tasks of yours and makes your life easy. Django is just like her! Your mother will cook for you, wash your clothes, perform all the routine tasks of yours so you can focus on your productive work. Same as your mother, Django comes with many built-in features such as user authentication, security, built-in admin side, Scalable, support for different databases, community, and many more so you can focus achieve rapid development.
 

What are the benefits of Django?

 

Authentication support

 
In almost all the sites we have authentications. Django knows this fact and frees you from the authentication burden. In many sites, we need restrictions about which role can access which page for example if we built a website for McDonald's the order taker shouldn't be allowed to alter the admin table. We can achieve access restriction with the help of a group and permission. Django will handle user authentication, groups, permission, cookie-based user session, and password hashing. Django comes with a built-in user model and allows you to add the custom fields to the user model.
 

Security

 
Django provides many security services such as CSRF protection, SQL injection. As many security tasks are handled by Django you can focus on building a website.
 
What is CSRF?
 
Consider I am an amazing make-up artist and with help of my make-up skill I can look exactly like the CEO of some bank. Now I can rob a bank and the CEO of the bank will be in jail. CSRF is the same kind of attack. In CSRF attack fraud users will use credentials of authenticate/real users to execute an action without that user's knowledge.
 
Django allows protection from this attack with the help of CSRF_token. Consider that bank has given token(secret key) to the CEO of a bank to perform any high-level task. In this case, even if I look like CEO(even if I have other user credentials) I will not have a token, and the bank will not allow me to perform any high-level task. 
 
What is SQL Injection? 
 
In other languages like C#.net, we write SQL query but hackers can provide malicious input through website form to access or delete data from the database. To solve this problem in Django we don't write query but we write query parameters. These query parameters are used to construct a query. Query parameters provided by the user can be malicious so they are escaped. This functionality makes sure only valid parameters are passed to construct quey.
 

Built-in Admin interface

 
In other languages such as PHP, we spend several days or months to create the admin side of the website. In most of the admin tables, we only want to perform CRUD (Create-Read-Update-Delete) operation. In Django, You have to just provide a model(table structure) and Django will create the admin side with CRUD functionality!! Isn't it amazing?! Django also allows you to customize your admin site, for example, you can select which fields of the table will be displayed on the dashboard.
 

Scalable

 
Django allows you to build a highly scalable website that can handle millions of users. We all have used Instagram, Mozilla, and Pinterest. Do you know which technology they use? Yes, your guess is right. They all use Django. You can boost the performance of your site with caching, load balancing, webserver to handle static files, database optimization, etc. To boost the performance of your site Django provides many classes for managing the cache and support different databases.
 

Support for different database

 
If you have used google translater, you provide your sentence, and google translate will convert your sentence into your preferred language. In Django, we write query parameters. We provide these query parameters to a database and the underlying database drivers will use these parameters to generate queries. As we don't write queries in a specific language we can easily move from one database backend to another database backend. Django supports the following databases.
  • PostgreSQL 
  • SQLite
  • MySQL
  • Oracle
  • MariaDB 

Documentation and community

 
As all the services provided by your mother are free, Django also provides all the services free. Django is an open-source python web framework that is supported by a large and active community of developers. You can join the Django forum to ask your Django project related question. https://forum.djangoproject.com/ Django provides amazing documentation. The documentation covers each topic with theory and examples. 
 

Ready-made documentation from comments of project

 
In all company-level projects, we have to create documentation for the project. This document contains all the detail of the project. Django can create documentation from comments in your project so you can look at a single place to know what is the task of each model and view. To create the documentation you have to perform a basic setup and the entire documentation will be ready for you.
 

Conclusion 

 
Django is an open-source Python web framework. Django is used by many well-known sites to achieve scalability. In short, the Django framework is simple, secure, fast, and scalable.


Similar Articles