mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.8.x] Fixed #24197 -- Added clearing of staticfiles caches on settings changes during tests
Cleared caching in staticfiles_storage and get_finder when
relevant settings are changed.
Backport of 2730dad0d7 from master
This commit is contained in:
@@ -156,3 +156,24 @@ def root_urlconf_changed(**kwargs):
|
||||
from django.core.urlresolvers import clear_url_caches, set_urlconf
|
||||
clear_url_caches()
|
||||
set_urlconf(None)
|
||||
|
||||
|
||||
@receiver(setting_changed)
|
||||
def static_storage_changed(**kwargs):
|
||||
if kwargs['setting'] in {
|
||||
'STATICFILES_STORAGE',
|
||||
'STATIC_ROOT',
|
||||
'STATIC_URL',
|
||||
}:
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
staticfiles_storage._wrapped = empty
|
||||
|
||||
|
||||
@receiver(setting_changed)
|
||||
def static_finders_changed(**kwargs):
|
||||
if kwargs['setting'] in {
|
||||
'STATICFILES_DIRS',
|
||||
'STATIC_ROOT',
|
||||
}:
|
||||
from django.contrib.staticfiles.finders import get_finder
|
||||
get_finder.cache_clear()
|
||||
|
||||
Reference in New Issue
Block a user