I am using http response to handle exception in my website. I want to show proper message / validation during create and update data. But It shows HTTP responses like Bad Request , Internel server error. Here is my code:
from django import http from rest_framework import viewsets class SaleViewSet(viewsets.ModelViewSet): def create(self, request, *args, **kwargs): data = request.data try: // Some code return http.JsonResponse(response) except Exception as e: logger.error(e) return http.HttpResponseBadRequest(content=e) In dialog box message it shows ,"Bad Request". Instead of "Bad Request" in dialog box message I want to show custom message.
I want to do ,
except Exception as e: logger.error(e) return http.HttpResponseBadRequest(My message) https://stackoverflow.com/questions/67052161/change-http-response-message-django April 12, 2021 at 11:05AM
没有评论:
发表评论