1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #32316 -- Deferred accessing __file__.

Deferred accessing the module-global variable __file__ because the
Python import API does not guarantee it always exists—in particular, it
does not exist in certain "frozen" environments. The following changes
advanced this goal.

Thanks to Carlton Gibson, Tom Forbes, Mariusz Felisiak, and Shreyas
Ravi for review and feedback.
This commit is contained in:
William Schwartz
2021-01-04 12:04:28 -06:00
committed by Mariusz Felisiak
parent cfe47b7686
commit 9ee693bd6c
5 changed files with 46 additions and 11 deletions

View File

@@ -7,8 +7,6 @@ from django.template.loader import get_template
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
ROOT = Path(__file__).parent
@functools.lru_cache()
def get_default_renderer():
@@ -33,7 +31,7 @@ class EngineMixin:
def engine(self):
return self.backend({
'APP_DIRS': True,
'DIRS': [ROOT / self.backend.app_dirname],
'DIRS': [Path(__file__).parent / self.backend.app_dirname],
'NAME': 'djangoforms',
'OPTIONS': {},
})