Store html in database in django
Hello I'm trying to store HTML code in the database with Django but facing a problem with escape characters.
here's an object that I'm trying to store but
{
"data": "<div class=\"read\" id=\"search\">Google</div>"
}
here's what I'm getting in database.
<div class="read" id="search">Google</div>
I tried to store with Model.objects.create()
this becomes a problem to parse too much HTML in javascript then. JSON object gets confused with the double-quotes. the solution is I want to store data in database with backslashes \ as well so it can be parsed correctly as a JSON object.
Have you tried a triple slash? Two to create an escaped backslash and then one to escape the doublequote
{
"data": "<div class=\\\"read\\\" id=\\\"search\\\">Google</div>"
}