Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda