0

How can I create custom response for permission classes

The response now is:

{"detail": "Authentication credentials were not provided."}

The response I want:

{
  "status": 403,
  "message": "Authentication credentials were not provided",
  "response": {....}
}
rijalanupraj
  • 56
  • 1
  • 4
  • Does this answer your question? [Django rest\_framework custom error message](https://stackoverflow.com/questions/51665260/django-rest-framework-custom-error-message) – JPG Dec 07 '20 at 04:35
  • Did you get a fix to this? – Arun T Mar 28 '23 at 23:29

1 Answers1

0

According to the official docs here you would need to override the .handle_exceptions method in your View to customize the responses.

Shown here in the official docs is how to make a custom exception handler.

Dharman
  • 30,962
  • 25
  • 85
  • 135
jakuta
  • 130
  • 8