Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Django 坚持在我放入页面上的 a> 标记的链接之前添加当前路径:示例:
<h6><a href="{{ officialUrl }}">Read More</a></h6>
现在假设 officialUrl 是“www.google.com” - Django 将改为链接到“http://www.mysite.com/this/page/www.google.com”
知道如何解决这个问题吗?
Django 没有这样做,浏览器这样做是因为您没有指定协议。标签内的正确链接通常以其他协议或其他协议<a>开头。简单地说不是一个正确的链接。http://XXX://www.google.com
<a>
http://
XXX://
www.google.com
www.google.com不是网址。
http://www.google.com/是。
http://www.google.com/
由于前者不是 URL,因此您的浏览器(注意,您的浏览器,而不是 Django - 查看 HTML 输出以确认这一点)将假定它与当前页面相关。