Vivek S
Vivek S

Reputation: 5540

django redirect to parent of iframe from view

I am having a web page rendered via iframe. On successfully submitting the form in iframe, i gave,

 return HttpResponseRedirect("www.google.com")

But the target page is also getting loaded within iframe. How to specify the parent to reload from django view?

Upvotes: 2

Views: 2891

Answers (1)

rafek
rafek

Reputation: 635

Just return some html:

redirect_template.html:

<html>
    <head>
        <script>
            window.top.location.href = '{{ redirect_url }}';
        </script>
    </head>
    <body></body>
</html>

Instead of:

return HttpResponseRedirect("www.google.com")

Use:

return TemplateResponse(request, 'redirect_template.html', {'redirect_url':'www.google.com'}

Upvotes: 11

Related Questions