Home > Mobile >  How can I set the accepted content type in django view
How can I set the accepted content type in django view

Time:12-15

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?

CodePudding user response:

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?

  • Related