Fix TemplateDoesNotExist when using django-nested-admin by returning custom template for other third-party packages. #341 (#342)

This commit is contained in:
Andrey
2023-12-28 19:43:56 +03:00
committed by GitHub
parent ff0380977e
commit 6a7a230964
2 changed files with 7 additions and 0 deletions
@@ -74,6 +74,9 @@ def get_admin_interface_setting(setting):
@register.simple_tag() @register.simple_tag()
def get_admin_interface_inline_template(template): def get_admin_interface_inline_template(template):
template_path = template.split("/") template_path = template.split("/")
if template_path[0] != "admin":
# return costume inline template for other packages
return template
template_path[-1] = "headerless_" + template_path[-1] template_path[-1] = "headerless_" + template_path[-1]
return "/".join(template_path) return "/".join(template_path)
+4
View File
@@ -131,6 +131,10 @@ class AdminInterfaceTemplateTagsTestCase(TestCase):
"admin/edit_inline/stacked.html" "admin/edit_inline/stacked.html"
) )
self.assertEqual(headless_template, "admin/edit_inline/headerless_stacked.html") self.assertEqual(headless_template, "admin/edit_inline/headerless_stacked.html")
headless_template = templatetags.get_admin_interface_inline_template(
"nesting/admin/inlines/tabular.html"
)
self.assertEqual(headless_template, "nesting/admin/inlines/tabular.html")
def test_get_active_date_hierarchy_none(self): def test_get_active_date_hierarchy_none(self):
changelist = Mock() changelist = Mock()