I've written a small view which contains some html embedded into one of the list arrays. When I use that list item in a template, the data is interpreted by the template as a literal string rather than html. How do I get django to not ignore html tags inside of a variable?
views.py
def home(request, username='Pedro'):
template_name = 'main/index.html'
url = "https://www.duolingo.com/users/{}".format(username)
getUserData(url)
context = {
'username': username,
'wordLists': wordlists,
'explanations': explanations,
'words': words,
}
# print(context)
return render(request, template_name, context)
def getUserData(url):
response = requests.get(url)
userdata = response.json()
for language in userdata['language_data']:
for index in userdata['language_data'][language]['skills']:
if index.get('levels_finished') > 0:
wordList = index.get("words")
wordlists.append(wordList)
explanations.append(index.get("explanation"))
for wordItem in wordList:
words.append(wordItem)
template
{% block content %}
{% for e in explanations %}
{{ e }}
{% endfor %}
{% endblock %}