Pyhon framework Django aka backend

Laptop

In development, a framework is a set of ready-made libraries and tools that help create web applications. For example, I will describe how Django, written in the Python programming language, works.

The first step is a request from a user goes to a router (URL dispatcher) which decides what function to call to process the request. The decision is made on the basis of a list of rules consisting of a regular expression and the name of the function: if this or that URL, then this is the function.

The function called by the router is called the view. It can contain any business logic, but in most cases it does one of two things: either it takes data from the database, prepares it, and returns it to the front end; or it takes data from a form, checks it, and saves it to the database.

Application data is stored in a database (DB). Most often relational databases are used. This is when there are tables with preset columns and these tables are linked together through one of the columns.

Data in the database can be created, read, changed, and deleted. Sometimes you see the abbreviation CRUD (Create Read Update Delete) for these actions. To query the data in the database, a special language SQL (structured query language) is used.

In Django, models are used to manipulate the database. They allow you to describe tables and make queries in familiar to developers Python, which is much more convenient. This convenience comes at a price: such queries are slower and more limited compared to pure SQL.

The data obtained from the database is prepared in a view to be sent to the front end. They can be put in a template and sent as an HTML file. But in case of single-page application this happens only once, when HTML page is generated and all JS scripts are attached to it. In other cases the data is serialized and sent in JSON format.

Jones Kenneth

Learn More →