title: Django Admin - Filter ManyToManyField with through model
body: <p>How can I filter a queryset inside the Admin page of an object that has a <code>ManyToManyField</code> relation with a manually defined <code>through</code> model?</p>
  
  <p>Given models.py</p>
  
  <pre><code>class Foo(models.Model):
      foo_field1 = models.CharField(max_length=50)
  
  class Main(models.Model):
      main_field1 = models.CharField(max_length=50)
      m2mfield = models.ManyToManyField(Foo, through="FooBar")
  
  class FooBar(models.Model):
      main = models.ForeignKey(Main, on_delete=models.CASCADE)
      foo = models.ForeignKey(Foo, on_delete=models.CASCADE)
      new_field = models.CharField(max_length=50)
  </code></pre>
  
  <p>Inside admin.py </p>
  
  <pre><code>class M2MInlineAdmin(admin.TabularInline):
      model = Main.m2mfield.through
      extra = 1
  
  class MainAdmin(admin.ModelAdmin):
     inlines = [M2MInlineAdmin,]
     ...
  
      def formfield_for_manytomany(self, db_field, request, **kwargs):
          print('called formfield_for_manytomany')
          return super().formfield_for_manytomany(db_field, request, **kwargs)
  
      def get_field_queryset(self, db, db_field, request):
          print('called get_field_queryset')
          return super().get_field_queryset(db, db_field, request)
  </code></pre>
  
  <p>I try to access both of these methods, but none of them are called if I specify a <code>through</code> table. However, they do get called if the ManyToMany relation is simply defined as like this:</p>
  
  <pre><code>class Main(models.Model):
      main_field1 = models.CharField(max_length=50)
      m2mfield = models.ManyToManyField(Foo)
  </code></pre>
  
  <p>Is there a method to filter the queryset when a through table is specified (while being able to access the <code>request</code> context)?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The methods are indeed called when the ManyToManyField has a <code>through</code> model specified, only if there are no <code>fieldsets</code> specified inside the <code>modelAdmin</code> class.</p>
  
  <p>How to access these methods when <code>fieldsets</code> are defined?</p>