Django REST framework is a powerful and flexible toolkit for building Web APIs.
Some reasons you might want to use REST framework:
- The Web browsable API is a huge usability win for your developers.
- Authentication policies including packages for OAuth1a and OAuth2.
- Serialization that supports both ORM and non-ORM data sources.
- Customizable all the way down - just use regular function-based views if you don't need the more powerful features.
- Extensive documentation, and great community support.
- Used and trusted by internationally recognised companies including Mozilla, Red Hat, Heroku, and Eventbrite.
Django Rest Framework makes it easy to use your Django Server as an REST API.
REST stands for "representational state transfer" and API stands for application programming interface.
You can build a restful api using regular Django, but it will be very tidious. DRF makes everything easy. For comparison, here is simple GET-view using just regular Django, and one using Django Rest Framework:
Regular:
from django.core.serializers import serialize
from django.http import HttpResponse
class SerializedListView(View):
def get(self, request, *args, **kwargs):
qs = MyObj.objects.all()
json_data = serialize("json", qs, fields=('my_field', 'my_other_field'))
return HttpResponse(json_data, content_type='application/json')
And with DRF this becomes:
from rest_framework import generics
class MyObjListCreateAPIView(generics.ListCreateAPIView):
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = MyObjSerializer
'OLD_달려라 > 호기심천국' 카테고리의 다른 글
노선 번호 체계 알아보기 (0) | 2021.01.30 |
---|---|
Pip vs Conda (0) | 2020.12.05 |
USB interface ] OHCI, UHCI, EHCI and XHCI controllers (0) | 2020.11.20 |
무료 이미지 ] 지브리 스튜디오 (0) | 2020.11.06 |
Convert *.jpg to *.png / 사진 파일 확장자 한 번에 변경하기 (0) | 2020.10.05 |
댓글