It's currently impossible to filter the admin interface by non-database fields, even if the fields are being selected in the queryset.
The attached patch lets you do something like this:
class Author(models.Model):
name = models.CharField(max_length=255)
class Book(models.Model):
author = models.ForeignKey(Author)
class AuthorAdmin(admin.ModelAdmin):
list_display = ['name', 'books']
list_filter = [models.IntegerField(verbose_name='number of books', name='num_books')]
def books(self, obj):
return obj.num_books
books.short_description = 'Number of books'
def queryset(self, request):
return super(AuthorAdmin, self).queryset(request).annotate(num_books=models.Count('book'))
admin.site.register(Author, AuthorAdmin)
admin.site.register(Book)
which would show all of the values for num_books in the available filters. (This particular example only works in MySQL, but could be applied to fields selected with .extra(select=...) instead of .annotate).