Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Wrapping the call to the Menu model get() in a try catch. #5

Merged
merged 1 commit into from

2 participants

@jamescooke

This isn't a major issue - more of a gripe.

When setting up versions of sites that use a menu, any templates that attempt to load a menu will throw DoesNotExist exception. This just bypasses that exception by returning [] so that we can get a site up and running and leave the managers to create and build menus.

Hope that makes sense.

@rossp rossp merged commit 9f14d5b into rossp:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +4 −1 menu/templatetags/menubuilder.py
View
5 menu/templatetags/menubuilder.py
@@ -68,7 +68,10 @@ def get_items(menu_name, current_path, user):
else:
menuitems = []
- menu = Menu.objects.get(slug=menu_name)
+ try:
+ menu = Menu.objects.get(slug=menu_name)
+ except Menu.DoesNotExist:
+ return []
for i in MenuItem.objects.filter(menu=menu).order_by('order'):
current = ( i.link_url != '/' and current_path.startswith(i.link_url)) or ( i.link_url == '/' and current_path == '/' )
Something went wrong with that request. Please try again.