Why do you need to use Django REST API?

早过忘川 提交于 2021-02-04 19:09:43

问题


Why do you need to use Django REST framework to make an API? Can't you just create routes like /api/createuser with normal Django and handle all of the backend logic from there as you would normally?


回答1:


You do not NEED to use Django REST framework to make an API

But if you are going to make a decent REST API in Django, DRF is a framework on top of Django that helps you building an API with following features:

  • Web browseable API, documentation autogeneration
  • Generic views auto building from models
  • Routers
  • Body parsers (auto content-negotiation)
  • Validators
  • Authentication
  • Permissions
  • Throttling
  • Data auto filtering via get params
  • 4 different pagination modes (number/offset/time)
  • API Versioning
  • Multiple response formats (.xml/.json/etc)
  • Exception format to current response format

You are free to reinvent the wheel and/or create a buggy/insecure REST API or you can choose to use a well thought and tested framework to help you build a good REST API.



来源:https://stackoverflow.com/questions/42617913/why-do-you-need-to-use-django-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!