Skip to content

Instantly share code, notes, and snippets.

@CryceTruly
Created October 19, 2020 00:14
Show Gist options
  • Save CryceTruly/5fba462bc8eb17ee5ac5351441af4dd5 to your computer and use it in GitHub Desktop.
Save CryceTruly/5fba462bc8eb17ee5ac5351441af4dd5 to your computer and use it in GitHub Desktop.
from django.http import JsonResponse
def error_404(request, exception):
message = ("The endpoint you are trying to access might "
"have been removed, "
"had its name changed, or is temporarily unavailable. "
"Please check the documentation here : "
"/ docs and try again later.")
response = JsonResponse(data={"message": message, 'status_code': 404})
response.status_code = 404
return response
def error_500(request):
message = ("The server encountered some issue. This will get resolved soon")
response = JsonResponse(data={"message": message, 'status_code': 500})
response.status_code = 500
print(response)
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment