Antonio Gamiz Delgado
Antonio Gamiz Delgado

Reputation: 2103

How can I set the accepted content type in django view

I have some views made in Django. I have realised that the endpoints do not fail with an unsupported media type if I call them with, for instance, binary data instead of json (they only accept json). So, my doubt is: how can I specify the allowed content type of an endpoint in django to make it return a 415 error code? Do I need to implement that logic by hand with a middleware?

Upvotes: 0

Views: 1048

Answers (1)

Mohamed Mohamedy
Mohamed Mohamedy

Reputation: 97

I don't think there's a built-in utility for that. But you can easily create a middleware for it yourself. Django: filtering expected content type?

Upvotes: 1

Related Questions