title: Temporary modify model's field value in Django
body: <p>I've got a problem with Django QuerySet:</p>
  
  <p>To not turn search results into a mess I first remove all the HTML tags from text with the following code:</p>
  
  <pre><code>re.sub("&lt;.*?&gt;", "", note.text)
  </code></pre>
  
  <p>which works fine.</p>
  
  <p>I need to modify all the notes and restore them back after searching is finished.</p>
  
  <p>I tried this code:</p>
  
  <pre><code>def remove_tags(notes):
      for note in notes:
          note.text = re.sub("&lt;.*?&gt;", "", note.text)
      return notes
  
  notes = remove_tags(Note.objects.all()) # Remove HTML tags in all the notes
  # ...
  found = notes.filter( # By the some reason it restores default value here
     Q(text__icontains=q) |
     Q(title__icontains=q)
  )
  </code></pre>
  
  <p>Example text:</p>
  
  <pre><code>&lt;span style="text-decoration:line-through"&gt;Todo&lt;/span&gt;
  </code></pre>
  
  <p>When I try to access text right after calling remove_tags everything seems to be fine:</p>
  
  <pre><code> notes = remove_tags(Note.objects.all())
   print(notes[0].text) # Will print 'Todo'
  </code></pre>
  
  <p>But when I do it after calling filter it looks like before:</p>
  
  <pre><code> notes = remove_tags(Note.objects.all())
   print(notes[0].text) # Will print 'Todo'
  
   filtered = notes.filter(text__icontains="line-through")
   print(filtered[0].text) # Will print '&lt;span style="text-decoration:line-through"&gt;Todo&lt;/span&gt;'
  </code></pre>
  
  <p>How can I filter notes without HTML tags?</p>