To see more details about serializers, view this Youtube clip
1. To view the JSON file in a formatted style, we added the Google Chrome extension, JSON FORMATTER:
BEFORE:
AFTER:
2. Previously, we manually used serializers to convert our query set into a list. The code is below to show the output in Step 1.
3. In Django, we can use serializer tools. In the API app folder, create a new file SERIALIZERS.PY:
4. Update our API\VIEWS.PY:
FROM manual serialization:
TO:
So, when you run the URL path again:
http://127.0.0.1:8000/api/v1/students/
5. Now, if you update your database model for a new record and use the GET button from Step 4, you will be able to use GET button to get the latest added records or you can simply refresh your page and that will be considered as a GET method.
6. Now using POSTMAN, you can copy the same API link paste it into the POSTMAN search bar and use GET method. It should return all records from the database. Simply click on + and add the same path we used from the browser. To use POSTMAN, this must be installed in your device.
7. To store data using the Django Rest Framework, update the VIEWS.PY to allow for POST method.
When you reload your page, then you can insert a new post:
8. To use POSTMAN, add the path again. Select BODY, then RAW, then JSON. Add your records then select select the SEND method.
9. Now, to see the newly inserted record, use the GET method. You will then see the newly added record.
No PDF file attached.