Search code examples
djangodjango-templateshref

Create a hyperlink to external website in django


I have a little problem about creating a hyperlink to an external website in django, for example in to the google.com I have in my html file something like :

Adres www: <a href="{{ det_wpisu.adres_www }}">{{ det_wpisu.adres_www }}</a> <br />

but the www address when I click showing me :

http://localhost:8000/detale/3/www.google.com

and returned the 404 page.


Solution

  • Ensure the variable det_wpisu.adres_www contains a full URL including https://, eg:

    context = {'det_wpisu.adres_www': 'https://www.google.com'}