by Esteban Santibáñez
Although I could have worked all the data directly in JavaScript and it might seem like an unnecessarily long road to get to the same result, the goal of this project is to understand how to manage and manipulate data from external APIs on the backend using Django.
In the same way, in the frontend JavaScript must handle the Json that it requests from the backend, so finally this work allowed me to train the sending and manipulation of Json both in the backend using Python and in the frontend using JavaScript.
In the backend we worked with Python, using its Django framework. In this case, the template is reduced to a single HTML document. This is because the objective is to create an interactive application, which does not have to update the page for each request.
To achieve this goal the main template will be manipulated by the static JavaScript files.
Django's functionality for this case is then to receive the requests from the frontend, request the external API for the data depending on the frontend's requirements, manipulate the data, and finally send this clean data via JSON to the frontend to be used by javascript
The home page starts by giving the user the option to enter a generation and based on the generation it suggests through the input names to enter.
The home page template loads once on application startup and then all its tags are modified via JavaScript.
All POST requests are sent from JavaScript, containing Json with the specification of the requested data.
Once the information is received from the backend, the JS file assigns the Json values to a Pokemon object, whose attributes are assigned to each DOM tag to display the characteristics of the requested pokemon.