From a7fd802436f10046e29b73d93d1129fe47f66dea Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 17 Jun 2015 02:19:12 -0400 Subject: [PATCH] Introspect object to be able to show table header even on empty object_list --- mayan/apps/common/templatetags/attribute_tags.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mayan/apps/common/templatetags/attribute_tags.py b/mayan/apps/common/templatetags/attribute_tags.py index e19390d901..cf3fe7ccc8 100644 --- a/mayan/apps/common/templatetags/attribute_tags.py +++ b/mayan/apps/common/templatetags/attribute_tags.py @@ -13,8 +13,20 @@ def object_property(value, arg): @register.filter def get_model_list_columns(obj): + try: + # Is it a query set? + obj = obj.model + except AttributeError: + # Is not a query set + try: + # Is iterable? + obj = obj[0] + except TypeError: + # It is not + pass + for key, value in model_list_columns.items(): - if isinstance(obj, key): + if key == obj or isinstance(obj, key): return value return []