Results in iframe

Asked

Viewed 82 times

0

I want to show the results of the variable "date in an iframe called "final.html". when I execute the code in iframe enters an error loop. there’s the code I developed

py views.

def notification_html(request):
    data = _notification(request, url)
    render(request, 'notification_result.html', {'notifications': data})
    return render(request,'final.html')

notification_result.html

<body>
    {% if notifications %}
        <ul>
           {% for n in notifications %}
                <li style="background-color:{{ n.notification_type.color }}"><b>{{ n.title }}</b> - {{ n.description }} </li>
            {% endfor %}
        </ul>
    {% else %}
        <p>No notifications.</p>
    {% endif %}
    </body>

final.html

<body>
<iframe width="100%" height=auto style="border: none" src="notification_result.html" name="iframe_notification"></iframe>
Hi and welcome this page contains the iframe
</body>

The code works perfectly without the iframe

  • What is the number of Notifications in {% for n in Notifications %}?

  • I’ve already solved the problem by creating a method that calls iframe and iframe calls the notifition_html method.

  • Pnelson, if you have solved the problem, please put the solution as an answer so that other users find it if they come to this question.

1 answer

1


Solved: The solution was to create a method that calls iframe and iframe calls the notifition_htmlv2 method.

def notification_html(request):
    url = request.META["QUERY_STRING"]
    return render(request, 'TTS Corporate.html', {"notes": '/notification_htmlv2/?' + url})


def notification_htmlv2(request):
    url = request.META["QUERY_STRING"]
    urls = decode(url)
    data = _notification(request, urls)
    return render(request, 'notification_result.html', {'notifications': data})

final.html

<iframe width="100%" src="{{ notes }}">
<p>Your browser does not support iframes.</p></iframe>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.