mirror of https://github.com/django/django.git
Improved performance of STATIC_URL and MEDIA_URL setting access.
Run `add_script_prefix()` on first access, rather than on every time.
This commit is contained in:
parent
bac5777bff
commit
7dbbe65647
|
@ -76,6 +76,12 @@ class LazySettings(LazyObject):
|
|||
if self._wrapped is empty:
|
||||
self._setup(name)
|
||||
val = getattr(self._wrapped, name)
|
||||
|
||||
# Special case some settings which require further modification.
|
||||
# This is done here for performance reasons so the modified value is cached.
|
||||
if name in {'MEDIA_URL', 'STATIC_URL'} and val is not None:
|
||||
val = self._add_script_prefix(val)
|
||||
|
||||
self.__dict__[name] = val
|
||||
return val
|
||||
|
||||
|
@ -149,14 +155,6 @@ class LazySettings(LazyObject):
|
|||
)
|
||||
return self.__getattr__('PASSWORD_RESET_TIMEOUT_DAYS')
|
||||
|
||||
@property
|
||||
def STATIC_URL(self):
|
||||
return self._add_script_prefix(self.__getattr__('STATIC_URL'))
|
||||
|
||||
@property
|
||||
def MEDIA_URL(self):
|
||||
return self._add_script_prefix(self.__getattr__('MEDIA_URL'))
|
||||
|
||||
|
||||
class Settings:
|
||||
def __init__(self, settings_module):
|
||||
|
|
Loading…
Reference in New Issue