1๐
โ
You are returning a JsonResponse
, but with status code 200, so that means that, according to the status code, the request was successful.
We thus can return a JsonResponse
with a status code outside the 200-399 range, for example a 400 HTTP response:
if some_condition:
success_meesage = f'success'
return JsonResponse(
{'success':'success','success_msg':success_meesage}
)
else:
error_message=f'there is an error into your two dates please make sure check in smaller than check out'
return JsonResponse(
{'success':False,'error_taken':True,'error_message':error_message},
status=400
)
Source:stackexchange.com