From 8e457afe22a6e9fc27930f552c33bb6e3b119470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20=C5=A0ulcs?= Date: Mon, 2 Jan 2017 17:28:11 +0200 Subject: [PATCH] Port 1.10 changes, default value for MenuManager. --- suit/menu.py | 2 +- suit/templatetags/suit_menu.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/suit/menu.py b/suit/menu.py index e5c6c346..93c73044 100644 --- a/suit/menu.py +++ b/suit/menu.py @@ -43,7 +43,7 @@ def __init__(self, available_apps, context, request): # Variable available_apps structure: # https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#adminsite-methods - self.available_apps = available_apps + self.available_apps = available_apps or [] self.context = context self.request = request diff --git a/suit/templatetags/suit_menu.py b/suit/templatetags/suit_menu.py index 3cb14250..700dbbc2 100644 --- a/suit/templatetags/suit_menu.py +++ b/suit/templatetags/suit_menu.py @@ -28,9 +28,12 @@ def get_menu(context, request): try: from django.contrib import admin template_response = get_admin_site(request.current_app).index(request) - available_apps = template_response.context_data['app_list'] - except Exception: - pass + # Django 1.10 removed the current_app parameter for some classes and functions. + # Check the release notes. + except AttributeError: + template_response = get_admin_site(context.request.resolver_match.namespace).index(request) + + available_apps = template_response.context_data['app_list'] if not available_apps: logging.warn('Django Suit was unable to retrieve apps list for menu.')