Building a REST API
In the previous chapter, we learned about templates and class-based views. These concepts greatly help expand the range of functionalities we can provide to the user on the frontend (in their web browser). However, that is not sufficient to build a modern web application. Web apps typically have the frontend built with an entirely separate library, such as ReactJS or AngularJS. These libraries provide powerful tools for building dynamic user interfaces but do not communicate directly with our backend Django code or database. The frontend code simply runs in the web browser and does not have direct access to any data on our backend server. Therefore, we need to create a way for these applications to “talk” to our backend code. One of the best ways to do this in Django is by using REST APIs.
APIs are used to facilitate interaction between different pieces of software, and they communicate using Hypertext Transfer Protocol (HTTP). This is the standard...