Is it possible to use filter_horizontal
for a field which is a ManyToManyField
with an intermediate table such as with those without intermediate tables?
e.g:
class A(models.Model):
f1 = models.ManyToManyField(B)
f2 = models.ManyToManyField(C, through='T')
class B(models.Model):
pass
class C(models.Model):
pass
class T(models.Model):
a = models.ForeignKey(A)
c = models.ForeignKey(C)
class AAdmin(admin.ModelAdmin):
filter_horizontal = ('f1', 'f2', )
When you have a many to many field with an intermediate table, it's not possible to display the regular, filter horizontal, or filter vertical widget. The reason for this is that the intermediate table may have extra fields that can not be displayed in those widgets.
It is possible to display the related model as an inline. See the docs on working with many-to-many intermediary models for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With