Skip to content

Commit

Permalink
use django's strip tags instead of re
Browse files Browse the repository at this point in the history
  • Loading branch information
R. van der Vegt committed Feb 4, 2020
1 parent 0228072 commit 67f9147
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions arctic/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import csv
import json
from collections import OrderedDict
import re

import extra_views
from django.conf import settings
Expand All @@ -24,7 +23,10 @@
from django.shortcuts import redirect, render, resolve_url
from django.urls import NoReverseMatch, reverse
from django.utils.formats import get_format
from django.utils.html import mark_safe
from django.utils.html import (
mark_safe,
strip_tags,
)
from django.utils.http import is_safe_url, quote
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
Expand Down Expand Up @@ -654,7 +656,6 @@ def csv_file_response(self):
writer = csv.writer(response)
writer.writerow(titles)

re_strip_tags = re.compile(r'<.*?>')
m2m_fields = [m2m_f.attname for m2m_f in model._meta.many_to_many]
for obj in self.get_object_list():
row = []
Expand All @@ -675,7 +676,7 @@ def csv_file_response(self):
field_value = ", ".join(
[str(obj) for obj in field_value.get_queryset()]
)
row.append(re.sub(re_strip_tags, '', str(field_value)).strip())
row.append(strip_tags(field_value))
writer.writerow(row)

return response
Expand Down

0 comments on commit 67f9147

Please sign in to comment.