13

I have to open the result page using render_to_response on a new tab.

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
Vivek S
  • 5,384
  • 8
  • 51
  • 72

4 Answers4

20

Django is server-side, opening in a new tab is client-side. So use an <A> with a target="_blank"

http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=target%3Dblank

But of course spawning new windows/tabs is annoying for the user, so try not to do that after all.

Adam Vandenberg
  • 19,991
  • 9
  • 54
  • 56
9

Most the time, loading the page in a new tab can be a real pain in the ar** for the user. Nevertheless it can still be necessary sometimes. If you really need to render your POST results in a new tab, use the target="_blank" as an attribute of your <form>.

Pegasus
  • 709
  • 9
  • 11
0

this was problem when i was passing the dynamic URL in DTL. i also solved by putting the target="_blank" after the href closed.

      <h3 class="card-title">
                        <i class="fas fa-bell fa-2x mr-1"></i>
                        <a href="{% url 'alerts' site=data.site.name  %}  " target ="_blank">Notifications </i></a>
                     </h3>
0

<a></a> with target="_blank" below can open url in a new tab:

<a href="https://www.google.com/" target="_blank">Google</a>

And, <a></a> without target="_blank" below can open url in the current tab:

<a href="https://www.google.com/">Google</a>
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129