Skip to content

Commit

Permalink
Raise NotAcceptable if suffix or query format is not acceptable
Browse files Browse the repository at this point in the history
  • Loading branch information
JourneyBean authored Nov 18, 2024
1 parent b31413d commit 00e5065
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rest_framework/negotiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 00e5065

Please sign in to comment.