Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-menu-generator-ng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
AlekSIS®
Libraries
django-menu-generator-ng
Commits
c92262f2
Verified
Commit
c92262f2
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Catch 404 exception if current path cannot be resolved
Closes
#1
parent
8144c406
No related branches found
No related tags found
1 merge request
!2
Resolve "related_views breaks 404/403 pages"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
menu_generator/menu.py
+6
-3
6 additions, 3 deletions
menu_generator/menu.py
with
6 additions
and
3 deletions
menu_generator/menu.py
+
6
−
3
View file @
c92262f2
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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment