diff --git a/suit/templatetags/suit_menu.py b/suit/templatetags/suit_menu.py index 07c61f2c..0d58d743 100644 --- a/suit/templatetags/suit_menu.py +++ b/suit/templatetags/suit_menu.py @@ -3,6 +3,13 @@ from django.contrib.admin import AdminSite from django.core.handlers.wsgi import WSGIRequest from django.core.urlresolvers import reverse, resolve + +try: + from django.utils.six import string_types +except ImportError: + # For Django < 1.4.2 + string_types = basestring, + import warnings from suit.config import get_config @@ -107,7 +114,7 @@ def make_menu(self, config): def make_app(self, app_def): if isinstance(app_def, dict): app = app_def.copy() - elif isinstance(app_def, str): + elif isinstance(app_def, string_types): if app_def == '-': app = self.make_separator() else: @@ -246,7 +253,7 @@ def process_models(self, app): def make_model(self, model_def, app_name): if isinstance(model_def, dict): model = model_def.copy() - elif isinstance(model_def, str): + elif isinstance(model_def, string_types): model = self.make_model_from_native(model_def, app_name) else: raise TypeError('MENU list item must be string or dict. Got %s' @@ -447,7 +454,7 @@ def make_menu_from_old_format(self, conf_order): if isinstance(order, (tuple, list)): app_name = order[0] models_order = order[1] if len(order) > 1 else None - if isinstance(app_name, str): + if isinstance(app_name, string_types): new_app['app'] = app_name elif isinstance(app_name, (tuple, list)): mapping = ('label', 'url', 'icon', 'permissions') @@ -456,7 +463,7 @@ def make_menu_from_old_format(self, conf_order): if models_order and isinstance(models_order, (tuple, list)): models = [] for model in models_order: - if isinstance(model, str): + if isinstance(model, string_types): models.append({'model': model}) elif isinstance(model, (list, tuple)): mapping = ('label', 'url', 'permissions')