title: On the fly modification of Django QuerySet objects
body: <p>I'm trying to add two attributes to every object in the queryset and add one more to a specific subset:</p>
  
  <pre><code>causelist_data = CauseHierarchy.objects.filter(cause_set_version_id=cause_set_version_id
      ).extra(order_by=['sort_order']
      ).prefetch_related('cause_id','parent_id')
  
  for c in causelist_data:
      # adding this attribute works
      c.display_name = c.cause_id.cause_name + " (" + c.cause_id.acause + ")"
      if len(c.path_to_top_parent.split(',')) == 1:
          # adding this attribute works as well
          c.immediate_parent = c.path_to_top_parent.split(',')[-1]
      else:
          c.immediate_parent = c.path_to_top_parent.split(',')[-2]
  
      # this is the problem
      parent = causelist_data.filter(cause_id=c.immediate_parent)[0]
      parent.is_parent = True
  </code></pre>
  
  <p>The modification works when I add a display name to each object and when I add an immediate_parent attribute based on a conditional. The problem arises when I try to set an is_parent attribute to objects that have been identified as children by pulling their id as each object identifies its parent in the iteration.</p>
  
  <p>In the shell I tried to print the <code>parent</code> object within the loop and it has the is_parent attribute, but when I look at causelist_data outside of the loop it has both the display_name and the immediate_parent attributes. I also tried to update the parent object after the filter (<code>parent = causelist_data.filter(cause_id=c.immediate_parent).update(is_parent=True)</code>), but it looks like I can't add an attribute like that, only update.</p>
  
  <p>Am I missing something here? Is my lookup incorrect?</p>