Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django rest framework: How to change error response format globally

All the error messages return from django default validators ends with a dot (.). Is there anyway to remove that last dot from all messages globally.

Or, If someone help me to find a way to catch these error returning function, I can trim the last dot if exists in that section.

Sample error messages.

{
  "email": [
    "This field may not be blank."
  ]
}


{
  "email": [
    "Enter a valid email address."
  ]
}
like image 850
Arun SS Avatar asked Sep 16 '25 08:09

Arun SS


1 Answers

You can use Restframework's exception handler. Please have a look.

like image 149
Mohammad Mustaqeem Avatar answered Sep 18 '25 06:09

Mohammad Mustaqeem