0

My question is very similar to this one, except my problem is that my frontend page is in another server, an Angular application.

Basically, what I need is to send a redirect response to my Angular frontend when user faces a 500 error, but also would like to receive admin e-mails with stack traces. This only happens when the response is a 500, not the 302 returned by the handler500 redirection.

Emanuel Kozerski
  • 379
  • 1
  • 2
  • 11

1 Answers1

0

you can basically send an email and then redirect the user to the URL

from django.shortcuts import redirect
def send_mail():
   ...

def handler500(request):
    send_mail_function()
    return redirect("http://external-site.com/")

You can follow this tutorial for email sending.

Mamed
  • 95
  • 4
  • 16
  • Sorry for a late response. This very email is my point. I don't have a way to generate the yellow exception email with stack trace and everything that Django generates when a 500 happens, in the sense of, what would be the content of that send_mail_function()? Or some other approach. – Emanuel Kozerski Nov 25 '21 at 20:26