From 00e5065fa4dc5f05c9ecacb55e23449548eeeeae Mon Sep 17 00:00:00 2001 From: Johnson Liu Date: Mon, 18 Nov 2024 17:00:48 +0800 Subject: [PATCH] Raise NotAcceptable if suffix or query format is not acceptable --- rest_framework/negotiation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest_framework/negotiation.py b/rest_framework/negotiation.py index b4bbfa1f54..95ec70bb82 100644 --- a/rest_framework/negotiation.py +++ b/rest_framework/negotiation.py @@ -2,7 +2,6 @@ Content negotiation deals with selecting an appropriate renderer given the incoming request. Typically this will be based on the request's Accept header. """ -from django.http import Http404 from rest_framework import exceptions from rest_framework.settings import api_settings @@ -85,7 +84,10 @@ def filter_renderers(self, renderers, format): renderers = [renderer for renderer in renderers if renderer.format == format] if not renderers: - raise Http404 + raise exceptions.NotAcceptable( + detail="Could not satisfy the request format suffix or query.", + available_renderers=renderers + ) return renderers def get_accept_list(self, request):