在 django 中创建指向外部网站的超链接

kil*_*ees 4 django href django-templates

我在 django 中创建指向外部网站的超链接时遇到了一些问题,例如我的 html 文件中的 google.com 的超链接如下:

Adres www: <a href="{{ det_wpisu.adres_www }}">{{ det_wpisu.adres_www }}</a> <br />
Run Code Online (Sandbox Code Playgroud)

但当我点击时显示的 www 地址:

http://localhost:8000/detale/3/www.google.com
Run Code Online (Sandbox Code Playgroud)

并返回404页面。

nem*_*ign 5

确保变量det_wpisu.adres_www包含完整的 URL,包括https://,例如:

context = {'det_wpisu.adres_www': 'https://www.google.com'}
Run Code Online (Sandbox Code Playgroud)