Edx-ace emails theming issue using microsites

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

How to reproduce:

  • Two microsites with different color themes

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
  • edx-ace uses django-templates, and that is different from most other theme templates
  • custom loaders described here
  • under the hood, the problem occurs when loader calls django.template.loaders.filesystem.Loader 's get_template_sources method. sourceone of the solutions – override the get_dirs method in the ThemeFilesystemLoader like this:
    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 :slight_smile:

I’ve already created the Jira ticket for this issue: [CRI-243] Email templates are cached for all microsites - JIRA

1 Like


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