# Edx-ace emails theming issue using microsites

**URL:** <https://discuss.openedx.org/t/edx-ace-emails-theming-issue-using-microsites/6139>\
**Category:** Development\
**Tags:** theming\
**Created:** [November 23, 2021, 12:38pm UTC](https://discuss.openedx.org/t/edx-ace-emails-theming-issue-using-microsites/6139 "2021-11-23T12:38:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evgen\_Dyudyunov](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/evgen_dyudyunov/32/3702_2.png) [@Evgen\_Dyudyunov](https://discuss.openedx.org/u/Evgen_Dyudyunov)\
**Post date:** [November 23, 2021, 12:38pm UTC](https://discuss.openedx.org/t/edx-ace-emails-theming-issue-using-microsites/6139/1 "2021-11-23T12:38:07Z")

</div>

Email templates are cached, so theming doesn’t work on microsites.

**How to reproduce:**  
Preconditions:

- Two microsites with different color themes

STR:  
We’ll need to send emails from two microsites, example flow:

- As a staff, log in to two microsites;
- Go to the membership section of the course instructor tab of any course;
- Use the Batch Enrollment section functionality to send emails;
- As a user, check received emails theming.

**AR** : Email template is cached after the first sending and is not updated for different microsite email notifications.  
**ER** : Email template is unique for every microsite

We’ve found that problem relates to Django template loaders caching.

**Investigation results are:**

- edx-ace searches for the templates [here](https://github.com/edx/edx-ace/blob/77d3a4c20f949e7dc5a21ad847bfbe53a556436b/edx_ace/renderers.py#L68)
- edx-ace uses django-templates, and that is different from most other theme templates
- custom loaders described [here](https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/theming/template_loaders.py)
- under the hood, the problem occurs when loader calls `django.template.loaders.filesystem.Loader` 's `get_template_sources` method. [source](https://github.com/django/django/blob/main/django/template/loaders/filesystem.py#L28)one of the solutions – override the `get_dirs` method in the [ThemeFilesystemLoader](https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/theming/template_loaders.py#L23) like this:

```auto
    def get_template_sources(self, template_name):
       if 'edx_ace' in template_name:
           self.dirs = self.engine.dirs
           theme_dirs = self.get_theme_template_sources()
           if isinstance(theme_dirs, list):
               self.dirs = theme_dirs + self.dirs
       return super().get_template_sources(template_name)

```

- Another possible solution - replace Django templates with mako templates for edx-ace.  
The solution with replacing Django templates with Mako is probably better because it’s less invasive.

We’ve tried both solutions and each of them works.  
Please, help me decide what solution is more preferable so I could contribute 🙂

I’ve already created the Jira ticket for this issue: [[CRI-243] Email templates are cached for all microsites - JIRA](https://openedx.atlassian.net/browse/CRI-243)

---

<div class="post-metadata">

**Author:** ![Evgen\_Dyudyunov](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/evgen_dyudyunov/32/3702_2.png) [@Evgen\_Dyudyunov](https://discuss.openedx.org/u/Evgen_Dyudyunov)\
**Post date:** [November 25, 2021, 8:08am UTC](https://discuss.openedx.org/t/edx-ace-emails-theming-issue-using-microsites/6139/2 "2021-11-25T08:08:17Z")

</div>

Update:

- an issue reproduces with non-email templates (e.g., logout.html)

---

<div class="post-metadata">

**Author:** ![Rohan](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Rohan](https://discuss.openedx.org/u/Rohan)\
**Post date:** [July 5, 2022, 12:24pm UTC](https://discuss.openedx.org/t/edx-ace-emails-theming-issue-using-microsites/6139/3 "2022-07-05T12:24:57Z")

</div>

Awesome. As if it wasn’t bad enough before that the open edx devs literally never bother to triage a single “needs triage” good-faith bug report for years on end…now the jira site is completely full of spam!
