summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorWilliam Schwartz <wkschwartz@gmail.com>2021-01-04 12:04:28 -0600
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-04-01 14:33:30 +0200
commit9ee693bd6cf4074f04ec51c6f3cfe87cad392f12 (patch)
tree893e5fba17d522305a35e7f2380164cd57563472 /django/forms
parentcfe47b7686df0c4c87270a83d6d7f933323ed7e6 (diff)
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.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/renderers.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/django/forms/renderers.py b/django/forms/renderers.py
index dcf3d92302..ce3b7097e6 100644
--- a/django/forms/renderers.py
+++ b/django/forms/renderers.py
@@ -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': {},
})