how can I sort/order readonly_fields (see https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields)?
here is what I do:
class MyUserAdmin(UserAdmin):
readonly_fields = ('pinCount')
list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff', 'is_active', 'date_joined', 'last_login', 'pinCount')
def pinCount(self, instance):
return Pin.objects.filter(user=instance).count()
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
In the admin it should be possible to sort the list by pinCount. Since it's not a direct database field, that's not possible according to the docs. Is there any way to do it?
Thanks!