list filter does not work

i add list_filter to my model admin does not work

class ProductAdmin(admin.ModelAdmin):
    fields = [
        "category", "title", "description", "free_delivery", "create_date", "update_date"
    readonly_fields = ["create_date", "update_date"]
    inlines = [PricingInline]
    list_display = ["category", "title", "description", "free_delivery", "create_date", "update_date"]
    list_filter = ["category"]
    search_fields = ["title"]
    search_help_text = _("search by title of product")

You’re going to need to be more explicit about what you think is wrong here.

You don’t appear to have any entries in Product, so there’s nothing to be filtered.

oh :sweat_smile::sweat_smile:. I thought the filter section would be shown, but it is empty.

Quoting directly from the docs in the section titled Using a field name and an explicit FieldListFilter

List filters typically appear only if the filter has more than one choice. A filter’s has_output() method controls whether or not it appears.

1 Like