0

i could not display the html data sent from python in the html page.

when i open the html in view source mode, it thing data is rendered as messed

html code

<table border="1">
<tr>
<th>servername</th>
<th>cpu</th>
<th>memory</th>
<th>cdrivespace</th>
<th>ddrivespace</th>
<th>fdrivespace</th>
<th>gdrivespace</th>
<th>pdrivespace</th>
<th>kdrivespace</th>
{{ data }}
</table>

python view

    data = callFileReaderMain( form.cleaned_data['session_key'] )

    return render(request,'marketplace_output.html',{'data' : data })

view source code

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>marketplace output server details</title>
</head>
<body>

<table border="1">
<tr>
<th>servername</th>
<th>cpu</th>
<th>memory</th>
<th>cdrivespace</th>
<th>ddrivespace</th>
<th>fdrivespace</th>
<th>gdrivespace</th>
<th>pdrivespace</th>
<th>kdrivespace</th>
&lt;tr&gt;&lt;td&gt;W01GCTIAPP01A&lt;/td&gt;&lt;td&gt;3.0&lt;/td&gt;&lt;td&gt;93.0&lt;/td&gt;&lt;td&gt;42.0&lt;/td&gt;&lt;td&gt;40.0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;/tr&gt;
</table>
</body>
</html>

 see the pic of the final page

1 Answer 1

3

In your html template, add a safe tag:

{{ data|safe }}
Sign up to request clarification or add additional context in comments.

2 Comments

But make sure you trust the source of data because by marking it safe, you're also opening up the possibility of script injections.
Sure noted let me try and let u know

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.