From 1148fea3dcf33219140a629067355e83d97b6c8c Mon Sep 17 00:00:00 2001 From: sai09111995 Date: Mon, 2 Feb 2026 15:22:01 +0530 Subject: [PATCH 1/2] Improve clarity in APIView documentation --- docs/api-guide/views.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md index 9c9bd9af6a..5b7e8692c0 100644 --- a/docs/api-guide/views.md +++ b/docs/api-guide/views.md @@ -10,7 +10,8 @@ source: > > — [Reinout van Rees][cite] -REST framework provides an `APIView` class, which subclasses Django's `View` class. +REST framework provides an `APIView` class, which subclasses Django’s base `View` class. + `APIView` classes are different from regular `View` classes in the following ways: @@ -19,7 +20,9 @@ REST framework provides an `APIView` class, which subclasses Django's `View` cla * Any `APIException` exceptions will be caught and mediated into appropriate responses. * Incoming requests will be authenticated and appropriate permission and/or throttle checks will be run before dispatching the request to the handler method. -Using the `APIView` class is pretty much the same as using a regular `View` class, as usual, the incoming request is dispatched to an appropriate handler method such as `.get()` or `.post()`. Additionally, a number of attributes may be set on the class that control various aspects of the API policy. +Using the `APIView` class is very similar to using a regular Django `View` class. +As usual, the incoming request is dispatched to an appropriate handler method such as `.get()` or `.post()`. + For example: From abf90308c1cffc451c3c77daa4140606bd458e4f Mon Sep 17 00:00:00 2001 From: sai09111995 Date: Thu, 5 Feb 2026 18:39:58 +0530 Subject: [PATCH 2/2] Clarify APIView.dispatch request lifecycle in docstring --- rest_framework/views.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/rest_framework/views.py b/rest_framework/views.py index 327ebe9032..8edf8fae2f 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -490,9 +490,22 @@ def raise_uncaught_exception(self, exc): # be overridden. def dispatch(self, request, *args, **kwargs): """ - `.dispatch()` is pretty much the same as Django's regular dispatch, - but with extra hooks for startup, finalize, and exception handling. + Dispatch the incoming request to the appropriate handler method. + + This method implements the core request/response lifecycle for + Django REST Framework views: + + 1. Wraps the incoming Django HttpRequest in a REST framework Request. + 2. Performs content negotiation, authentication, permission, and + throttling checks. + 3. Resolves and calls the appropriate HTTP method handler + (e.g. get(), post(), put()). + 4. Handles any exceptions raised during processing and converts + them into appropriate Response objects. + 5. Finalizes and returns the response with proper rendering + and headers applied. """ + self.args = args self.kwargs = kwargs request = self.initialize_request(request, *args, **kwargs)