mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Ref #23919 -- Replaced some os.path usage with pathlib.Path.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import inspect
|
||||
import os
|
||||
from importlib import import_module
|
||||
from pathlib import Path
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
@@ -331,15 +331,15 @@ class TemplateDetailView(BaseAdminDocsView):
|
||||
else:
|
||||
# This doesn't account for template loaders (#24128).
|
||||
for index, directory in enumerate(default_engine.dirs):
|
||||
template_file = os.path.join(directory, template)
|
||||
if os.path.exists(template_file):
|
||||
with open(template_file) as f:
|
||||
template_file = Path(directory) / template
|
||||
if template_file.exists():
|
||||
with template_file.open() as f:
|
||||
template_contents = f.read()
|
||||
else:
|
||||
template_contents = ''
|
||||
templates.append({
|
||||
'file': template_file,
|
||||
'exists': os.path.exists(template_file),
|
||||
'exists': template_file.exists(),
|
||||
'contents': template_contents,
|
||||
'order': index,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user