Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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>"
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!