I’m parsing some HTML using Beautiful Soup, and occasionally the HTML it returns includes some special characters, such as — (long dash) and ® (register symbol).
I’m currently storing this html as a string in my db as is, and as a result when I display these variables in my templates the special characters appear as they do above. I’ve tried unescaping the characters using {{ variable|safe }} but that didn’t work.
What is the right way to store, and then display, these types of special characters in Django?
What you’re looking for is here:
http://www.crummy.com/software/BeautifulSoup/documentation.html#Entity Conversion
You’ll want to use the convertEntities parameter and encode them as unicode.
The final line should be something like
To display them again