mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-21 14:05:16 +03:00
Raise NotAcceptable if suffix or query format is not acceptable
This commit is contained in:
parent
b31413d46d
commit
00e5065fa4
|
@ -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 @@ class DefaultContentNegotiation(BaseContentNegotiation):
|
|||
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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user