Skip to content

APIView

Base APIView classes with serializer and pagination helpers. See the APIView guide for the dispatch loop and helper method surface.

APIView

Bases: APIViewHelpersMixin, APIView

options

options(
    request: Request, *args: Any, **kwargs: Any
) -> Response

Handles the OPTIONS request, tolerating views without a serializer_class.

AsyncAPIView

Bases: APIViewHelpersMixin, APIView

dispatch async

dispatch(
    request: HttpRequest, *args: Any, **kwargs: Any
) -> Response

Async equivalent of APIView.dispatch.

options async

options(
    request: Request, *args: Any, **kwargs: Any
) -> Response

Async equivalent of APIView.options. Metadata generation inspects the serializer and can reach the database, so it runs in a thread instead of on the event loop.

ainitial async

ainitial(
    request: Request, *args: Any, **kwargs: Any
) -> None

Runs anything that needs to occur prior to calling the method handler.

aperform_authentication async

aperform_authentication(request: Request) -> None

Performs authentication on the incoming request.

acheck_permissions async

acheck_permissions(request: Request) -> None

Checks if the request should be permitted, raising on failure.

acheck_object_permissions async

acheck_object_permissions(
    request: Request, obj: Any
) -> None

Checks if the request should be permitted for a given object.

acheck_throttles async

acheck_throttles(request: Request) -> None

Checks the throttles on the incoming request.

ahandle_exception async

ahandle_exception(exc: Exception) -> Response

Handles any exception that occurs, by returning an appropriate response, or re-raising the error.

afinalize_response async

afinalize_response(
    request: Request,
    response: Response,
    *args: Any,
    **kwargs: Any,
) -> Response

Returns the final response object after any processing.

avalidated_serializer async

avalidated_serializer(
    *,
    data: Any = None,
    serializer_class: type[BaseSerializer[Any]]
    | None = None,
    **kwargs: Any,
) -> BaseSerializer[Any]

Returns a serializer with the request data validated, awaiting ais_valid when available.

aserialized_response async

aserialized_response(
    instance: Any,
    *,
    many: bool = False,
    status: int = status.HTTP_200_OK,
    serializer_class: type[BaseSerializer[Any]]
    | None = None,
    post_fetches: Any = None,
    headers: Any = None,
) -> Response

Returns a Response containing the serialized instance, awaiting any post-fetch helpers.

apaginated_response async

apaginated_response(
    queryset: Any,
    *,
    serializer_class: type[BaseSerializer[Any]]
    | None = None,
    pagination_class: type[BasePagination] | None = None,
    post_fetches: Any = None,
    headers: Any = None,
) -> Response

Returns a paginated Response for the given queryset, using async paginator hooks when available.