Answer the question
In order to leave comments, you need to log in
How to display part of the page (html code) instead of one of the variables in a django template?
The essence of the question is to display html not as plain text with tags.
The project parses recipes from various pages, and to confirm the correct operation of the parser, it is necessary to display the div with the recipe, discarding the description, comments, and so on. I can find this div with beautifulsoup, but I can't display it as html.
#views.py
...
mdict = {'header_h1': u'Исходный текст с рецептом', 'recipe_part': logList}
mdict.update(csrf(request))
return render_to_response('success.html', mdict, context_instance=RequestContext(request))
#success.html
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”>
<html lang=”ru”>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
...
<body>
<h1>{{ header_h1 }}</h1>
{% block content %}{{ recipe_part }}{% endblock %}
{% block footer %}
<hr>
...
{% endblock %}
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question