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

master
Andrey 2023-12-28 19:43:56 +03:00 committed by GitHub
parent ff0380977e
commit 6a7a230964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -74,6 +74,9 @@ def get_admin_interface_setting(setting):
@register.simple_tag()
def get_admin_interface_inline_template(template):
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]
return "/".join(template_path)

View File

@ -131,6 +131,10 @@ class AdminInterfaceTemplateTagsTestCase(TestCase):
"admin/edit_inline/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):
changelist = Mock()