Python – opens HttpResponseRedirect, Django in a new tab

opens HttpResponseRedirect, Django in a new tab… here is a solution to the problem.

opens HttpResponseRedirect, Django in a new tab

Is there any way in Django to redirect to URLs in a new tab in Django View via HttpResponseRedirect

return HttpResponseRedirect(url)

The URL value is similar to https://www.google.com/maps/place/The+Reservoire/

Solution

Django, and even the HTTP specification, does not provide a way to open redirects in a new tab. However, you have some other options.

You can send a response using a piece of JavaScript that opens the page in a new tab: window.open(url, '_blank');

Another approach is to use <a> with target="_blank"

Related Problems and Solutions