Skip to content

Commit

Permalink
Avoid using __file__ at module level in django.forms.renderers
Browse files Browse the repository at this point in the history
The module-level constant `ROOT` is used only in one place. The method it's used
in is already a cached property, so there shouldn't be a real performance issue.
`ROOT` is undocumented, so I'm assuming it's an obscure private symbol that no
one will miss.
  • Loading branch information
wkschwartz committed Jan 4, 2021
1 parent 100097c commit 54d539c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions django/forms/renderers.py
Expand Up @@ -7,8 +7,6 @@
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():
Expand All @@ -33,7 +31,7 @@ def get_template(self, template_name):
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': {},
})
Expand Down

0 comments on commit 54d539c

Please sign in to comment.