在django app中嵌入了一个外部链接

che*_*hen 2 django django-templates

我在myproject/templates/items/index.html中添加了一个像这样的链接

<a href="www.google.com">Search More</a>
Run Code Online (Sandbox Code Playgroud)

我希望当用户点击它时,她会访问google.com.但是,现在的结果是此链接是"myhost/items/www.google.com"而不是"www.google.com".

(我正在修改现有的应用程序,我不得不承认我还没有完全阅读django doc)

Ami*_*dav 12

每当您将外部链接传递给<a href=''>标记时,请始终使用http.所以它会像:

<a href="http://www.google.com">Search More</a>
Run Code Online (Sandbox Code Playgroud)


Yar*_*nST 5

你忘记了协议:

<a href="http://www.google.com">Search More</a>
Run Code Online (Sandbox Code Playgroud)