2

I checked several questions from here and tried several methods on my own but didn't work out.

I have a Pandas dataframe of product catalog which contains several columns, and there is a column called 'url', where it has url address to corresponding product.

I'm using Flask to display this dataframe via html, but url column remains as plain text, instead of clickable url.

But it ended up showing nothing in html result (even plain text of url were gone)

Can someone tell me what should I do to convert my plain text url column as clickable, and display it to flask html?

current code:

df['url'] = '<a href="' + df['url'] + '">' + '</a>'
return render_template('result.html',  tables=[df.to_html(classes='data',escape=False)], titles=result.columns.values)

1 Answer 1

1

If you can add some text inside your tag you will be able to see the link URL. Something like this

df['url'] = '<a href="' + df['url'] + '">' + df['url'] + '</a>'
Sign up to request clarification or add additional context in comments.

4 Comments

so I need to put df['url'] twice???? can you explain me how this works little more?
Yes, replace the above snipped with your code it will work.
visrey, I'm now trying to show this url in new tab. I found that there is a trick called /"target="_blank, but little confused where do I sneak this into my current existing code. is this right before </a> ?
df['url'] = '<a href="' + df['url'] + '" target="_blank">' + df['url'] + '</a>'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.