Skip to content

Theme Middleware

Andy Byers edited this page Sep 11, 2017 · 2 revisions

The Theme Override Middleware is a piece of code that does the following:

  1. Works out if there is a journal in the request object
  2. Attempts to fetch the theme setting for a journal and add that theme to the list of settings.TEMPLATES['DIRS']
  3. If no setting is found for the journal theme is set to default
  4. If no journal is found in the request object we set the theme to the request.press.theme
  5. Otherwise, set the theme to default as a failsafe

This means that for any given page request, we ensure the correct theme/templates are served so we don't get any mismatches (ie. Press theme showing for a Journal etc.)

This middleware is loaded in the settings.MIDDLEWARE_CLASSES variable and looks like:

'utils.template_override_middleware.ThemeEngineMiddleware',

Wiki has moved to read the docs.

Clone this wiki locally