# Including domain name in email error report

**URL:** <https://forum.djangoproject.com/t/including-domain-name-in-email-error-report/41025>\
**Category:** Using Django\
**Created:** [May 20, 2025, 10:10pm UTC](https://forum.djangoproject.com/t/including-domain-name-in-email-error-report/41025 "2025-05-20T22:10:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![osmium2259](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/osmium2259/32/24180_2.png) [@osmium2259](https://forum.djangoproject.com/u/osmium2259)\
**Post date:** [May 20, 2025, 10:10pm UTC](https://forum.djangoproject.com/t/including-domain-name-in-email-error-report/41025/1 "2025-05-20T22:10:01Z")

</div>

Hello,

I’ve implemented a simplified `ExceptionReporter` for sending error reports to email. I’ve overridden the `get_traceback_data` method to change the context included in the email templates. I would like to include the website domain in the error report (e.g., to distinguish between staging and production environments).

I was thinking of using the Sites framework (which I have installed) and adding the current site to the traceback data, so I could then get the domain from the site object. Here’s what I’m thinking:

```auto
def get_traceback_data(self):
    data = {
        'is_email': self.is_email,
        'request': self.request,
        'site': get_current_site(self.request),
        'server_time': timezone.now(),
    }
  
    if self.exc_type:
        data['exception_type'] = self.exc_type. __name__
  
    return data

```

However, I am unsure if calling `get_current_site` could raise an exception in some situations. For obvious reasons, I don’t want my exception reporter to raise an unhandled exception 😉

Another idea I had, was to use `request.get_host` to get the domain.

Thank you!

---

<div class="post-metadata">

**Author:** ![osmium2259](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/osmium2259/32/24180_2.png) [@osmium2259](https://forum.djangoproject.com/u/osmium2259)\
**Post date:** [May 22, 2025, 4:40pm UTC](https://forum.djangoproject.com/t/including-domain-name-in-email-error-report/41025/2 "2025-05-22T16:40:10Z")

</div>

Would anyone be able to give insight on this?
