Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
Passing numeric data containing < or > django to javascript

am having a problem with char inside numeric data, it's too large to be cleaned. anyways. I want to replace < and > from value. just posting relevant codes. views.py

def search_result(request):
    if request.method == "POST":
        ChemSearched = request.POST.get('ChemSearched')
        tarname = BINDLL.objects.filter(targetnameassignedbycuratorordatasource__contains=ChemSearched).exclude(ki_nm__isnull=True)[:120]
        
        return render(request, 'Search/search_result.html',{'ChemSearched':ChemSearched,'tarname':tarname})

Html side

<script>
     data=[{% for Bindll in tarname %} {
                group: '{{ Bindll.targetnameassignedbycuratorordatasource }}',
                     variable:'{{ Bindll.zincidofligand}}',
                     value: {{Bindll.ki_nm|safe}}
                    }, {% endfor %}];

which is used by graph d3.js. all go well unless I have '<' or '>' in value I'll have this result

Uncaught SyntaxError: Unexpected token '>' or if use escape value: {{Bindll.ki_nm|escape}} Uncaught SyntaxError: Unexpected token '&lt' any function to be used in Html side javascript to replace char or anything and keep only numeric like regex replace. thanks.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda