꿈꾸는 새벽하늘

[Clone Coding] Django-React Project: Task Manager Application (2) Create the API 본문

💻 Programming

[Clone Coding] Django-React Project: Task Manager Application (2) Create the API

rovemin 2023. 1. 25. 22:13

Install: django Rest Framework & django-cors-headers

 

settings.py 수정: Whitelisting React port

Whitelisting React port: let frontend of the application to interact with the API in django

 

serializers.py 생성

serializers.py: to convert the model instances to JSON so that the frontend can work with the received data easily
cf. JSON: the standard for data interchange on the web

 

views.py

 

urls.py

routers: basically make some queries

  • tasks: return a list of all the tasks or the todo items
  • task: return a single task item or todo item

 

🔍︎ localhost:8000/api

 

🔍︎ localhost:8000/api/tasks