My models are
class Test(models.Model):
name = models.CharField(max_length=255)
class Testrelated(models.Model):
name = models.CharField(max_length=255)
tests = models.ManyToManyField(Test, related_name='tests')
And admin:
class TestrelatedInline(admin.TabularInline):
extra = 0
model = models.Test.tests.through
filter_horizontal = ('name')
class TestAdmin(admin.ModelAdmin):
list_display = ('id', 'name')
search_fields = ('name',)
inlines = [
TestrelatedInline,
]
The problem is that .through has no the model fields. So I can not refer to any field using filter_horizontal.
<class 'app.admin.TestrelatedInline'>: (admin.E019) The value of 'filter_horizontal[0]' refers to 'name', which is not an attribute of 'app.Testrelated_tests'.
I have created a test stand https://gitlab.com/marataziat/testdjangoproject.