Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to open url in new tab from django?

Tags:

python

django

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

like image 908
Vivek S Avatar asked Mar 24 '11 06:03

Vivek S


People also ask

How do I name a URL in Django?

The most basic technique to name Django urls is to add the name attribute to url definitions in urls.py . Listing 2-16 shows how to name a project's home page, as well as how to reference this url from a view method or template.

What is URL tag in Django?

The URL template tag is a typical type of Tag in the Django Template Language framework. This tag is specifically used to add View URLs in the Template Files. In the HTML Template file, URL tags are used with the Anchor, <a href> attribute of HTML, which handles all the URLs in HTML.


2 Answers

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.

like image 69
Adam Vandenberg Avatar answered Sep 20 '22 17:09

Adam Vandenberg


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>.

like image 22
Pegasus Avatar answered Sep 19 '22 17:09

Pegasus