Parcourir la source

Fix KeyError for Django 1.5 #2

Denis K il y a 9 ans
Parent
commit
8087bd689e
2 fichiers modifiés avec 5 ajouts et 5 suppressions
  1. 4 4
      jet/modules.py
  2. 1 1
      jet/templatetags/jet_tags.py

+ 4 - 4
jet/modules.py

@@ -177,11 +177,11 @@ class AppList(DashboardModule):
 
         for app in app_list:
             app['models'] = filter(
-                lambda model: self.models is None or model['object_name'] in self.models or app['app_label'] + '.*' in self.models,
+                lambda model: self.models is None or model['object_name'] in self.models or app.get('app_label', app.get('name')) + '.*' in self.models,
                 app['models']
             )
             app['models'] = filter(
-                lambda model: self.exclude is None or model['object_name'] not in self.exclude and app['app_label'] + '.*' not in self.exclude,
+                lambda model: self.exclude is None or model['object_name'] not in self.exclude and app.get('app_label', app.get('name')) + '.*' not in self.exclude,
                 app['models']
             )
             app['models'] = list(app['models'])
@@ -218,11 +218,11 @@ class ModelList(DashboardModule):
 
         for app in app_list:
             app['models'] = filter(
-                lambda model: self.models is None or model['object_name'] in self.models or app['app_label'] + '.*' in self.models,
+                lambda model: self.models is None or model['object_name'] in self.models or app.get('app_label', app.get('name')) + '.*' in self.models,
                 app['models']
             )
             app['models'] = filter(
-                lambda model: self.exclude is None or model['object_name'] not in self.exclude and app['app_label'] + '.*' not in self.exclude,
+                lambda model: self.exclude is None or model['object_name'] not in self.exclude and app.get('app_label', app.get('name')) + '.*' not in self.exclude,
                 app['models']
             )
             app['models'] = list(app['models'])

+ 1 - 1
jet/templatetags/jet_tags.py

@@ -146,7 +146,7 @@ def get_menu(context):
                 app['current'] = True
                 current_found = True
 
-        if app['app_label'] in pinned:
+        if app.get('app_label', app.get('name')) in pinned:
             pinned_apps.append(app)
         else:
             apps.append(app)