id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 11008,dictsort and dictsortreversed template filters broken,ionut bizau,nobody,"Using dictsort or dictsortreversed template filters for a list of dictionaries which contain dates will break if some of the dates are None, even if the sort field is not one of the date fields! This happens when the list contains at least two dictionaries for which the sort keys are equal. Example: {{{ In [1]: from django.template import defaultfilters In [3]: from datetime import datetime In [4]: defaultfilters.dictsort([{'a': 1, 'b': datetime.now()}, {'a': 2, 'b': None}, {'a': 1, 'b': None}], ""a"") --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /XXX/ in () /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/django/template/defaultfilters.pyc in dictsort(value, arg) 470 var_resolve = Variable(arg).resolve 471 decorated = [(var_resolve(item), item) for item in value] --> 472 decorated.sort() 473 return [item[1] for item in decorated] 474 dictsort.is_safe = False TypeError: can't compare datetime.datetime to NoneType }}} My patch fixes this problem for both dictsort and dictsortreversed.",Bug,closed,Template system,dev,Normal,fixed,,,Accepted,1,0,1,1,0,0