2👍
✅
filter
returns a completely new QuerySet, so everything you changed in the previous QuerySet will be forgotten.
Let me suggest a different approach:
class Note(models.Model):
text = models.TextField()
...
def text_without_tags(self):
return re.sub("<.*?>", "", self.text)
Use this method when you need the content of the field without the tags. This is cleaner: modifying variables in place is the way to end writing spaghetti code.
Edit:
Try something like Bleach instead of regular expressions.
Source:stackexchange.com