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

194
Views
Is there any 'safe' keyword of Django template filter in Python or JavaScript?

I'm using ckeditor for description field which allows the user to format text.

This is what I'm saving in my description field:

<div class="ql-editor" data-gramm="false" data-placeholder="Compose an epic..." contenteditable="true">
<p><strong>Lösungen, die mit Ihrem Unternehmen wachsen. Gern berate ich Sie zu allen Steuerfragen. Vereinbaren Sie ein individuelles Informationsgespräch. Annette Wolff Ι Steuerberaterin</strong></p>
</div>
<div class="ql-clipboard" tabindex="-1" contenteditable="true">
</div>
<div class="ql-tooltip ql-hidden">
<a class="ql-preview" target="_blank" href="about:blank"></a><input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL"><a class="ql-action"></a><a class="ql-remove"></a>
</div>

To show it in a proper format I'm using description|safe filter in Django template which shows the description like this:

Lösungen, die mit Ihrem Unternehmen wachsen. Gern berate ich Sie zu allen Steuerfragen. Vereinbaren Sie ein individuelles Informationsgespräch. Annette Wolff Ι Steuerberaterin

But how can I handle it with an Ajax call as I cannot use the Django template safe filter keyword?

Is there any way to handle it in JavaScript, jQuery, or in a Python file?

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

0

You can simply return description as your html using JsonResponse in your AJAX view:

from django.http import JsonResponse

def myview(request):
    html = "<h1>Some text</h1>"
    return JsonResponse(html, safe=False)

You can also use mark_safe as mark_safe(html) in your view

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!