title: How to show different inlines depending of current object field value
body: <p>Given a model named <code>MainModel</code> and a <code>RelatedModel</code>, where the later has a <code>ForeignKey</code> field to <code>MainModel</code>:</p>
  
  <pre><code>class MainModel(models.Model):
      name = models.CharField(max_length=50)
      type = models.BooleanField()
  
  class RelatedModel1(models.Model):
      main = models.ForeingKey(MainModel):
      name = models.CharField(max_length=50)
  
  class RelatedModel2(models.Model):
      main = models.ForeingKey(MainModel):
      name = models.CharField(max_length=50)
  </code></pre>
  
  <p>and the corresponding ModelAdmin classes:</p>
  
  <pre><code>class RelatedModel1InlineAdmin(admin.TabularInline):
      model = RelatedModel1
  
  class RelatedModel2InlineAdmin(admin.TabularInline):
      model = RelatedModel2
  
  class MainModel(admin.ModelAdmin):
      inlines = [RelatedModel1, RelatedModel2]
  </code></pre>
  
  <p>And that's the default behavior, you get two inlines, one for every related model. The question is how to hide completely all the inlines when the <code>MainModel</code> instance is being created (the <code>ModelAdmin</code>'s <code>add_view</code>), and to show the inlines for <code>RelatedModel1</code> when the <code>type</code> field of the <code>MainModel</code> instance is <code>True</code>, and show the inlines for <code>RelatedModel2</code> when <code>False</code>.</p>
  
  <p>I was going to create a <a href="http://users.rcn.com/python/download/Descriptor.htm">descriptor</a> for the <code>ModelAdmin.inline_instances</code> attribute, but I realized that I need access to the object instance being edited, but it is passed around as parameters.</p>
  
  <p>Any help?</p>
  
  <p>Thanks!</p>