Skip to content

Commit

Permalink
Fix TemplateDoesNotExist when using django-nested-admin by return…
Browse files Browse the repository at this point in the history
…ing custom template for other third-party packages. #341 (#342)
  • Loading branch information
markdrrr committed Dec 28, 2023
1 parent ff03809 commit 6a7a230
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions admin_interface/templatetags/admin_interface_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ def test_get_admin_interface_inline_template(self):
"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()
Expand Down

0 comments on commit 6a7a230

Please sign in to comment.