Fixed the is_in_section template filter to deal with when the request is not None but the resolver_match is None in the accounting application.

This commit is contained in:
依瑪貓 2020-08-13 22:14:33 +08:00
parent b266a02634
commit f2455bb946

View File

@ -209,6 +209,8 @@ def is_in_section(request: HttpRequest, section_name: str) -> bool:
"""
if request is None:
return False
if request.resolver_match is None:
return False
view_name = request.resolver_match.view_name
return view_name == section_name\
or view_name.startswith(section_name + ".")