I have 2 models related by M2M type of relationship. I use filter_horizontal
in the admin for editing my entities.
However, I would like to have a control on what is presented in the left side of the filter_horizontal
widget. For example, I would like to filter and show only those entities that match some certain criteria.
I think I found it!
ModelAdmin.formfield_for_manytomany(db_field, request, **kwargs)
This subject is always tricky in the Django admin. I suppose that in the inline defenition you can do something like this:
class BAdmin(admin.TabularInline): ...
https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_queryset