diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py index ff814bfd7b..0de1b6cbe2 100644 --- a/django/utils/itercompat.py +++ b/django/utils/itercompat.py @@ -34,7 +34,7 @@ def groupby(iterable, keyfunc=None): keyfunc = lambda x:x iterable = iter(iterable) l = [iterable.next()] - lastkey = keyfunc(l) + lastkey = keyfunc(l[0]) for item in iterable: key = keyfunc(item) if key != lastkey: