python - Django Admin Filter by Related Field Count -


i using django 1.27 have 2 models

class publisher(models.model):     name = models.charfield(max_length=100)      def book_count(self)         return self.book_set.all().count()  class book(models.model):     publisher = models.foreignkey(publisher) 

and in publisther admin want able filter book count

class publistheradmin(admin.modeladmin):      list_filter = ('book_count')      .... 

how can work ?


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -