﻿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
9053	Fix admin sortable when using callable functions in list_display	rgl	nobody	"We can use callable functions when we define the ModelAdmin.list_display property, but when we try to short then, an TypeError exception is raised:

{{{
Exception Type:		TypeError
Exception Value:	getattr(): attribute name must be string
Exception Location:	/home/rgl/Projects/django/django-trunk/django/contrib/admin/views/main.py in get_ordering, line 160
}}}

The attached patch fixes this.


This problem can be seen in the following ModelAdmin example; it uses two callables ""admin_lat"" and ""admin_lng"":

{{{
from django.contrib import admin
from airports.models import Airport

# See ""callable"" at http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display
def admin_lat(airport):
    return '%.6f' % airport.lat
admin_lat.short_description = ""Latitude""
admin_lat.admin_order_field = 'lat'
def admin_lng(airport):
    return '%.6f' % airport.lng
admin_lng.short_description = ""Longitude""
admin_lng.admin_order_field = 'lng'

class AirportAdmin(admin.ModelAdmin):
    list_display = ('iata_code', 'name', admin_lat, admin_lng, 'tz', 'country')
    list_filter = ('country', )
    search_fields = ('=iata_code', )
admin.site.register(Airport, AirportAdmin)
}}}"		closed	contrib.admin	1.0		fixed			Accepted	1	0	0	0	0	0
