I
I
in8inity2016-01-08 23:53:32
Django
in8inity, 2016-01-08 23:53:32

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>

Tell me, pliz, how to treat / which section to read? By templates? Or by output (response)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2016-01-09
@in8inity

{{ recipe_part|safe}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question