Make comprehensive theme work with django templates.
Comprehensive theming did not work with django templates (used by course wiki). The reason it didn't work was that in order for the theme to work, theme template folder has to be added to django template dirs setting *before* django startup. After django startup, modifying `settings.DEFAULT_TEMPLATE_ENGINE['DIRS']` has no effect, because at that point the template engine is already initialized with a copy of the template dirs list. Instead of running the theme startup code as an autostartup hook, we manually run it *before* `django.setup()`. This is fine because theme startup code doesn't have to do anything else besides modifying some settings and doesn't actually need django to be initialized.
This commit is contained in:
@@ -14,6 +14,8 @@ from monkey_patch import third_party_auth
|
||||
import xmodule.x_module
|
||||
import cms.lib.xblock.runtime
|
||||
|
||||
from openedx.core.djangoapps.theming.core import enable_comprehensive_theme
|
||||
|
||||
|
||||
def run():
|
||||
"""
|
||||
@@ -21,6 +23,11 @@ def run():
|
||||
"""
|
||||
third_party_auth.patch()
|
||||
|
||||
# Comprehensive theming needs to be set up before django startup,
|
||||
# because modifying django template paths after startup has no effect.
|
||||
if settings.COMPREHENSIVE_THEME_DIR:
|
||||
enable_comprehensive_theme(settings.COMPREHENSIVE_THEME_DIR)
|
||||
|
||||
django.setup()
|
||||
|
||||
autostartup()
|
||||
|
||||
Reference in New Issue
Block a user