0Pricing
Django Academy · Lesson

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 APIView

All lessons in this course

  1. Installing and Configuring DRF
  2. Serializers: Model to JSON
  3. APIView and Function @api_view
  4. The Browsable API and Status Codes
← Back to Django Academy