title: Django accessing formset data
body: <p>I'm having difficulty accessing the data submitted through my formset. Here is my code:</p>
  
  <p>Template:</p>
  
  <pre><code>&lt;form action="" method="post"&gt;
      {% csrf_token %}
      {{ formset.management_form }}
      {% for form in formset %}
  
      {{ form.as_p }}
  
      {% endfor %}
  
      &lt;input type="submit" value="Submit"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>def addMembers(request, id, members):
      if request.user.is_authenticated():
          members = int(members)
          MemberFormSet = formset_factory(MemberForm, extra = members)
          if request.method == 'POST':
              print 'post'
              formset = MemberFormSet(request.POST)
              if formset.is_valid():
                  cd = formset.cleaned_data
                  for f in formset:
                      first_name = cd.first_name
                      last_name = cd.last_name
                      email = cd.email
                      house = House.objects.get(id = id)
                      member = Member(first_name = first_name, last_name = last_name, email = email, house = house, created_on = timezone.now())
                      member.save()
                  return HttpResponseRedirect(reverse('houses:controlPanel'))
          else:
              formset = MemberFormSet()
          return render_to_response('houses/add_members.html', {'formset' : formset}, context_instance = RequestContext(request))
      return HttpResponseRedirect(reverse('allauth.account.views.login'))
  </code></pre>
  
  <p>I've tried several ways of accessing the data aside from what is currently written including:
  <code>f['attribute']</code>
  <code>cd['attribute']</code>
  <code>request.POST['attribute']</code>
  <code>formset.cleaned_data['attribute']</code></p>
  
  <p>I get errors ranging from <code>u"Key 'email' not found in Form"</code> to <code>list indices must be integers, not str</code></p>
  
  <p>How should I be accessing the data submitted by a formset? Django's documentation fails to give a clear answer to this and searching around I find many different ways but none that have worked yet. Thanks for your help.</p>