Bulkmailer / BulkMailer-Backend

File opened without the with statement PTC-W0010
Anti-pattern
Critical
a year agoa year old
Use the with statement to open a file
136        Template_object = TemplateModel.objects.create(**data)
137        if Template_object.template == "null":
138            file = f"media/media/template/{data['html_file'].name}"
139            HTMLFile = open(file, "r")140            index = HTMLFile.read()
141            S = BeautifulSoup(index, "lxml")
142            Template_object.template = S.body.prettify()