Ticket #9053: admin_allow_callable_on_shorting.patch

File admin_allow_callable_on_shorting.patch, 1.0 KB (added by rgl, 16 years ago)
  • django/contrib/admin/views/main.py

     
    155155                    f = lookup_opts.get_field(field_name)
    156156                except models.FieldDoesNotExist:
    157157                    # See whether field_name is a name of a non-field
    158                     # that allows sorting.
     158                    # that allows sorting.  field_name can either be
     159                    # a callable function or a attribute name on the
     160                    # model.
    159161                    try:
    160                         attr = getattr(self.model, field_name)
     162                        if callable(field_name):
     163                            attr = field_name
     164                        else:
     165                            attr = getattr(self.model, field_name)
    161166                        order_field = attr.admin_order_field
    162167                    except AttributeError:
    163168                        pass
Back to Top