Django

Code

Ticket #2029: admin_model_list_sort_by_name_fixed_typo.patch

File admin_model_list_sort_by_name_fixed_typo.patch, 1.0 kB (added by Alex Dedul, 2 years ago)

Fixed typo in comments

  • django/contrib/admin/templatetags/adminapplist.py

    old new  
    4243                            }) 
    4344 
    4445                if model_list: 
    45                     model_list.sort() 
     46                    # Sort model_list by name key. 
     47                    # We have to use verbose decorate-sort-undecorate pattern 
     48                    # instead of key argument to sort() for python 2.3 compatibility 
     49                    # http://wiki.python.org/moin/SortingListsOfDictionaries 
     50                    decorated = [(x['name'], x) for x in model_list] 
     51                    decorated.sort() 
     52                    model_list = [x for key, x in decorated] 
     53 
    4654                    app_list.append({ 
    4755                        'name': app_label.title(), 
    4856                        'has_module_perms': has_module_perms,