diff --git a/wagtail/tests/context_processors.py b/wagtail/tests/context_processors.py new file mode 100644 index 0000000000..63d0ab683c --- /dev/null +++ b/wagtail/tests/context_processors.py @@ -0,0 +1,7 @@ +def do_not_use_static_url(request): + def exception(): + raise Exception("Do not use STATIC_URL in templates. Use the {% static %} templatetag instead.") + + return { + 'STATIC_URL': lambda: exception(), + } diff --git a/wagtail/tests/settings.py b/wagtail/tests/settings.py index a03b9d8873..6bbe14e561 100644 --- a/wagtail/tests/settings.py +++ b/wagtail/tests/settings.py @@ -48,6 +48,7 @@ if django.VERSION >= (1, 8): 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.request', + 'wagtail.tests.context_processors.do_not_use_static_url', ], }, }, @@ -55,6 +56,7 @@ if django.VERSION >= (1, 8): else: TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + ( 'django.core.context_processors.request', + 'wagtail.tests.context_processors.do_not_use_static_url', ) MIDDLEWARE_CLASSES = (