Skip to content
Snippets Groups Projects
Verified Commit c92262f2 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Catch 404 exception if current path cannot be resolved

Closes #1
parent 8144c406
No related branches found
No related tags found
1 merge request!2Resolve "related_views breaks 404/403 pages"
import copy import copy
import django import django
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured, Resolver404
from .utils import get_callable, parse_url, path_startswith from .utils import get_callable, parse_url, path_startswith
if django.VERSION >= (1, 10): # pragma: no cover if django.VERSION >= (1, 10): # pragma: no cover
...@@ -109,8 +109,11 @@ class MenuBase(object): ...@@ -109,8 +109,11 @@ class MenuBase(object):
if path_startswith(self.path, related_url): if path_startswith(self.path, related_url):
return True return True
# Resolve URL and check if it relates to a related views # Resolve URL and check if it relates to a related views
if resolve(self.path).func in self._get_related_views(item_dict): try:
return True if resolve(self.path).func in self._get_related_views(item_dict):
return True
except Resolver404:
return False
return False return False
def _is_root(self, item_dict): def _is_root(self, item_dict):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment