A.J.
A.J.

Reputation: 9005

how to apply an external url with django template

I am new to Django. I want to ask a basic question.

I have an anchor tag in the template

<a href="www.abc.com">website</a>

when I get the rendered template in the webpage, I get an url like this:

www.mydomain.com/my_current_page/www.abc.com

and actually it goes to the same url, while in html I can only find the href to be equal to:

www.abc.com

I also added target=_blank to open in the new page. Is this fine the way I am doing this?

Upvotes: 4

Views: 4891

Answers (1)

Paulo Bu
Paulo Bu

Reputation: 29794

You'll need to declare the anchor like this:

<a href="http://www.abc.com">website</a>

Otherwise the browser will interpret it like a relative url and will happen what you just explained.

Upvotes: 7

Related Questions