Django

Code

Ticket #6127: admin-ordering.patch

File admin-ordering.patch, 0.7 kB (added by gkelly, 1 year ago)

Admin foreignkey ordering fix

  • django/db/models/query.py

    old new  
    546546                if "." in col_name: 
    547547                    table_prefix, col_name = col_name.split('.', 1) 
    548548                    table_prefix = qn(table_prefix) + '.' 
     549                   if col_name.startswith('-'): 
     550                       col_name = col_name[1:] 
     551                       order = "DESC" 
    549552                else: 
    550553                    # Use the database table as a column prefix if it wasn't given, 
    551554                    # and if the requested column isn't a custom SELECT.