From a50a41d92c062ef066a5613f2fc22dbb0dd2036b Mon Sep 17 00:00:00 2001 From: tim watts Date: Thu, 2 Mar 2017 09:27:15 +0000 Subject: [PATCH] rm conditional and add docstring --- rest_framework/templatetags/rest_framework.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py index decf9cdae..d62ac4800 100644 --- a/rest_framework/templatetags/rest_framework.py +++ b/rest_framework/templatetags/rest_framework.py @@ -165,8 +165,13 @@ def format_value(value): @register.filter def items(value): - if hasattr(value, 'items'): - return value.items() + """ + Simple filter to return the items of the dict. Useful when the dict may + have a key 'items' which is resolved first in Django tempalte dot-notation + lookup. See issue #4931 + Also see: https://stackoverflow.com/questions/15416662/django-template-loop-over-dictionary-items-with-items-as-key + """ + return value.items() @register.filter