From 62254c5202e80a68f4fe6572a2be46a3d953de1a Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 21 Nov 2019 06:14:03 -0800 Subject: [PATCH] Simplified TemplateDetailView with pathlib.Path.read_text(). --- django/contrib/admindocs/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index cb25a7a5b1..cacdeb91a0 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -330,8 +330,7 @@ class TemplateDetailView(BaseAdminDocsView): for index, directory in enumerate(default_engine.dirs): template_file = Path(directory) / template if template_file.exists(): - with template_file.open() as f: - template_contents = f.read() + template_contents = template_file.read_text() else: template_contents = '' templates.append({