list_filter in admin.TabularInline

Hello,

I am trying to find out if it is possible to have a list_filter in admin.TabularInline.
I have tried to use it but it does not display any filter. But also I am not getting any error.
Can anyone address me to examples/documentation?
Something like the following:

models.py

from django.db import models

class Foo(models.Model):
    title = models.CharField(max_length=128)

    class Meta:
        verbose_name = "Foo"
        verbose_name_plural = "Foo"

    def __str__(self):
        pass

class Bar(models.Model):
    title = models.CharField(max_length=128)
    foo = models.ForeignKey(Foo)

    class Meta:
        verbose_name = "Bar"
        verbose_name_plural = "Bars"

    def __str__(self):
        return self.title

admin.py

from django.contrib import admin
from django import forms
from . import models

class BarInline(admin.TabularInline):
    model = models.Bar
    form = BarInlineForm
    list_filter = ['title']
    extra = 3

class FooAdmin(admin.ModelAdmin):
    inlines = [BarInline]

admin.site.register(models.Foo, FooAdmin)

What is your ultimate objective here? It’s not clear what you’re trying to accomplish from this.

Hi @KenWhitesell , suppose that for Foo #1 you have 100 of related Bar. Normally the TabularInLine display all the 100 Bars under Foo #1. I want to have a custom filter in the inline list of Bar like you have in ModelAdmin, where you have the right top menu and you can select values to apply as filters to your view. I do not want to statically filter the queryset. I want the user can dynamically change the filter. Do you get my point?

Yes, I think I follow you here.

Django does not directly provide that facility. You’ll need to implement it yourself.

You would need to add your own input widget (or selections or whatever) on the admin page for Foo to display/accept some type of filter. (You may need to do this as a custom form, or you might be able to do it by just adding a custom admin asset.)

You can then override the get_queryset method on your InlineModelAdmin-based class to apply those filters.

Ah ok I did not know it.
Thank you @KenWhitesell