title: Django admin form : dynamic fields list causes a KeyError which I can bypass just by pressing F5, why?
body: <p>Before exposing my bug, let me explain what I am trying to acheive.</p>
  
  <h2>Problem</h2>
  
  <p>In the django admin, when editing an object, I want the fields list to change according to the kind of object (defined by the field <code>kind</code>). For example, I have a blog post model:</p>
  
  <pre><code>KIND_LIST = (
      ('featured', 'Featured'),
      ('classic', 'Classic'),
  )
  
  class Post(models.Model):
      kind = models.CharField(max_length=200, choices=KIND_LIST)
      attribut1 = models.CharField(max_length=200)
      attribut2 = models.CharField(max_length=200)
  </code></pre>
  
  <p>When I am editing an <em>featured</em> post, I want do display only <code>attribut1</code> and when I want to display a <em>classic</em> post, I want to display only <code>attribut2</code>.</p>
  
  <h2>My solution</h2>
  
  <p>I override <code>get_form</code> so I can exclude some fields.</p>
  
  <pre><code>class BlogPostAdmin(admin.ModelAdmin):
  
      def get_form(self, request, obj=None, **kwargs):
          form = super(PollAdmin, self).get_form(request, obj, **kwargs)
          if obj and obj.kind == 'featured':
              self.exclude = ('attribut2',)
          elif obj and obj.kind == 'classic':
              self.exclude = ('attribut1',)
          return form
  
  admin.site.register(BlogPost, BlogPostAdmin)
  </code></pre>
  
  <h2>The bug</h2>
  
  <p>At first sight, it works, but on a specific use case, I got a bug. When I edit a <em>featured</em> post and <strong>then</strong> a <em>classic</em> post I got this error:</p>
  
  <pre><code>KeyError at /admin/blog/post/1/
  u"Key 'attribut2' not found in Form"
  </code></pre>
  
  <p>It didn't found the field to display. But, a simple F5 and it works again! I suppose there is some sort of cache somewhere because when I am editing only the same kind of post I don't get an error.</p>
  
  <p>Does anyone can help me and explain me why I got this error?</p>