• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

438
Views
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."
  ]
}
about 3 years ago · Santiago Trujillo
2 answers
Answer question

0

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

about 3 years ago · Santiago Trujillo Report

0

If you want to change all of them, you should override the field's default messages somewhere in the application initialization:

serializers.CharField.default_error_messages['blank'] = 'This field may not be blank'

For example, the blank message can be found here

about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error