Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flask jinja2 href not linking correctly

I have a jinja2 template that contains hrefs

<td><a href="{{entry.Url}}">Product URL</a></td>

However, when I run the application and click the link on the page I get the development server in front of the correct url. So it would look like the following in the browser:

http://121.1.2.1:8764/www.google.com/

When I just want the following link:

www.google.com

Any ideas on how I can get this to work?

Thanks!

like image 910
Lance Collins Avatar asked Jun 12 '13 01:06

Lance Collins


2 Answers

Without adding a prefix, the root of the URL will be your local environment. In this case it's your IP address.

To correct the issue, add a HTTPS prefix like so:

<a href="https://{{ entry.Url }}">{{ entry.Url }}</a>
like image 94
Liza Konopelko Avatar answered Oct 18 '22 00:10

Liza Konopelko


This worked for me while testing.

<a href="{{ ''.join(['http://', entry.Url]) }}">{{ entry.Url }}</a>

# entry.Url == www.google.com
# <a href="http://www.google.com">www.google.com</a>
like image 21
bnlucas Avatar answered Oct 18 '22 00:10

bnlucas