title: Django Model Formset: only track changes to those items that have been updated/saved in the set?
body: <p>So, I'm using Django's Model Formset to produce sets of forms for different data. It is working great, but I want to add a feature where when a user displays the formset and, say, updates 2 out of the 10 items, I can track just the 2 updated, and output a message like "You have updated 2 items" kind-of-thing.</p>
  
  <p>Do Django Model Formsets have a built in API for this? I can't seem to find it on the Django Docs.</p>
  
  <p>I've tried various approaches but keep getting this when using the code offered by Peter below:</p>
  
  <pre><code>'Attendance' object has no attribute 'has_changed.' 
  </code></pre>
  
  <p>If I switch form.has_changed to formset.has_changed(), I get </p>
  
  <pre><code>'list' object has no attribute 'has_changed'
  </code></pre>
  
  <p>My View and Post method</p>
  
  <pre><code>class AttendanceView(TemplateView):
  
      template_name = 'example.html'
  
      def changed_forms(self, formset):
          return sum(1 for form in formset if form.has_changed())
  
  def post(self, request, *args, **kwargs):
      formset = AttendanceFormSet(request.POST)
      if formset.is_valid():
          formset = formset.save()
          forms_changed = self.changed_forms(formset)
          context = self.get_context_data(**kwargs)
          context['total_changed_forms'] = forms_changed
          return self.render_to_response(context)
      else:
          return HttpResponse("POST failed")
  </code></pre>
  
  <p>So I figured it out, just change:</p>
  
  <pre><code>formset = formset.save() 
  </code></pre>
  
  <p>to</p>
  
  <pre><code>formset.save()
  </code></pre>