在 Django 中创建指向外部网站的超链接
Create a hyperlink to external website in django
我在 Django 中创建指向外部网站的超链接时遇到了一些问题,例如 google.com
我的 html 文件中有类似 :
的内容
Adres www: <a href="{{ det_wpisu.adres_www }}">{{ det_wpisu.adres_www }}</a> <br />
但是当我点击显示我的 www 地址时:
http://localhost:8000/detale/3/www.google.com
并返回了 404 页面。
确保变量 det_wpisu.adres_www
包含 完整 URL 包括 https://
,例如:
context = {'det_wpisu.adres_www': 'https://www.google.com'}
考虑使用 http
的嵌入解决方案。所以它会像:
<a href="http://www.google.com">Text</a>
在 Django 模板中添加 http:// 字符串很容易。不要修改视图 and/or 数据库,试试这个...
<a href="http://{{ det_wpisu.adres_www }}">{{ det_wpisu.adres_www }}</a>
我在 Django 中创建指向外部网站的超链接时遇到了一些问题,例如 google.com 我的 html 文件中有类似 :
的内容Adres www: <a href="{{ det_wpisu.adres_www }}">{{ det_wpisu.adres_www }}</a> <br />
但是当我点击显示我的 www 地址时:
http://localhost:8000/detale/3/www.google.com
并返回了 404 页面。
确保变量 det_wpisu.adres_www
包含 完整 URL 包括 https://
,例如:
context = {'det_wpisu.adres_www': 'https://www.google.com'}
考虑使用 http
的嵌入解决方案。所以它会像:
<a href="http://www.google.com">Text</a>
在 Django 模板中添加 http:// 字符串很容易。不要修改视图 and/or 数据库,试试这个...
<a href="http://{{ det_wpisu.adres_www }}">{{ det_wpisu.adres_www }}</a>