mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #24128 -- Made admindocs TemplateDetailView respect template_loaders.
Co-Authored-By: Author: Alexander Lazarević <laza@e11bits.com>
This commit is contained in:
parent
1df8983aa3
commit
b7154f811f
@ -404,8 +404,13 @@ class TemplateDetailView(BaseAdminDocsView):
|
||||
# Non-trivial TEMPLATES settings aren't supported (#24125).
|
||||
pass
|
||||
else:
|
||||
# This doesn't account for template loaders (#24128).
|
||||
for index, directory in enumerate(default_engine.dirs):
|
||||
directories = list(default_engine.dirs)
|
||||
for loader in default_engine.template_loaders:
|
||||
if hasattr(loader, "get_dirs"):
|
||||
for dir_ in loader.get_dirs():
|
||||
if dir_ not in directories:
|
||||
directories.append(dir_)
|
||||
for index, directory in enumerate(directories):
|
||||
template_file = Path(safe_join(directory, template))
|
||||
if template_file.exists():
|
||||
template_contents = template_file.read_text()
|
||||
|
8
tests/admin_docs/templates/view_for_loader_test.html
Normal file
8
tests/admin_docs/templates/view_for_loader_test.html
Normal file
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Template for Test</title>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
@ -138,6 +138,12 @@ class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
|
||||
html=True,
|
||||
)
|
||||
|
||||
def test_template_detail_loader(self):
|
||||
response = self.client.get(
|
||||
reverse("django-admindocs-templates", args=["view_for_loader_test.html"])
|
||||
)
|
||||
self.assertContains(response, "view_for_loader_test.html</code></li>")
|
||||
|
||||
def test_missing_docutils(self):
|
||||
utils.docutils_is_available = False
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user