我不知道为什么我要用标签直接获取html内容。。代码的其余部分可以,但内容不可以。
def ShowContent(content):
plantilla = get_template('index.html')
c = Context({"content": content})
renderizado = plantilla.render(c)
return renderizado
def ShowNextTen(request):
NextActQuery = Actividad.objects.all().order_by('fecha')
NextAct = "Listado actividades<br>"
for Act in range(0,10):
NextAct += '<div class="activity">'
NextAct += '<strong>' + NextActQuery[Act].titulo + '</strong><br>'
NextAct += NextActQuery[Act].tipo_evento + "<br>"
NextAct += NextActQuery[Act].fecha.strftime("%d-%m-%y") + "<br>"
NextAct += '</div>'
return HttpResponse(ShowContent(NextAct))
最佳答案
在模板中,使用:
{{ content|safe }}
see this answer