APIView and Function @api_view
Build endpoints two ways.
Two Ways to Build Endpoints
DRF lets you write endpoints as classes with APIView or as plain functions decorated with @api_view. Both speak the same JSON dialect.
The Class Style
APIView subclasses Django's View but gives you DRF's request parsing, content negotiation, and tidy response handling for free.
from rest_framework.views import APIViewAll lessons in this course
- Installing and Configuring DRF
- Serializers: Model to JSON
- APIView and Function @api_view
- The Browsable API and Status Codes