title: Conditional inline in Django admin?
body: <p>I'm trying to figure out a way to display the following RelativeInline only if Person.is_member is True. </p>
  
  <p>Current admin.py:</p>
  
  <pre><code>class RelativeInline(admin.TabularInline):
      model = Relative
      fk_name = 'member'
  
  class PersonAdmin(admin.ModelAdmin):
      inlines = [RelativeInline,]
      ordering = ('first_name',)
      list_filter = ('is_member',)
      search_fields = ('first_name', 'last_name',)
      date_hierarchy = 'member_date'
      list_display = ('first_name', 'last_name', 'is_member', 'member_date', 'photo')
  
  admin.site.register(Person, PersonAdmin)
  </code></pre>
  
  <p>The only hint I've been able to find is that I might be able to override get_formset, but I couldn't find a good example, so my feeble attempt didn't work. </p>
  
  <p>Here's my failed attempt:</p>
  
  <pre><code>class RelativeInline(admin.TabularInline):
      model = Relative
      fk_name = 'member'
  
  class PersonAdmin(admin.ModelAdmin):
      ordering = ('first_name',)
      list_filter = ('is_member',)
      search_fields = ('first_name', 'last_name',)
      date_hierarchy = 'member_date'
      list_display = ('first_name', 'last_name', 'is_member', 'member_date', 'photo')
  
      def get_formset(self, request, obj=None, **kwargs):
          if obj.is_member:
              inlines = [RelativeInline,]
          return super(PersonAdmin, self).get_formset(request, obj, **kwargs)
  
  admin.site.register(Person, PersonAdmin)
  </code></pre>
  
  <p>There are no errors generated by this code, but no inline appears regardless of whether or not Person.is_member is True or False. </p>
  
  <hr>
  
  <p>Update:
  A friend suggested I try changing:</p>
  
  <pre><code>inlines = [RelativeInline,]
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>self.inlines = [RelativeInline,]
  </code></pre>
  
  <p>but to no avail. I also tried:</p>
  
  <pre><code>PersonAdmin.inlines = [RelativeInline,]
  </code></pre>
  
  <p>but the result was the same -- no error, no inline.</p>