Masked Man Masked Man - 8 months ago 31
HTML Question

Django test can't find br tag

I use linebreaks in template. But the test can't find 'br' tag.

{{ book.short_description | linebreaks }}

This is the test

self.assertContains(response, "New<br></br>Lines")


You need to set html to True in order to handle text as HTML:

self.assertContains(response, "New<br></br>Lines", html=True);

Or you can use assertHTMLEqual. I hope this will help.