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

97
Vistas
How do i write a jQuery input string so that it works with Django query string

Am working on a name search app but having a challenge getting it to work with Django query string, the challenge which i observed comes from my JavaScript input type with ${input} string when added to Django query string eg. "address/get-name/?search=${input}" doesn't return the query object or the payload data, instead it return an empty list, but when i make search through the browser it return all search query data eg "address/get-name/?search=smith", Now how do i get input through my scripts without having to use the java scripts query input type ${input} with django so let i get a query string like this "address/get-name/?search=james" ? Here is my script, Am a novice in JavaScript

<script>
    new Autocomplete('#autocomplete',{

         search : input => {
             console.log(input)
             const url = "/address/get-names/?search=${input}"
             return new Promise(resolve => {
                
                 fetch(url)
                 .then( (response) => response.json())
                 .then( data => {
                    console.log(data.playload)
                     resolve(data.playload)
                     
                })
             })
         },
         renderResult : (result, props) =>{
             console.log(props)
             let group =  ''
             if (result.index % 3 == 0 ){
                 group = '<li class="group">Group</li>'
             }
             return '${group}<li ${props}><div class="wiki title">${result.name}</div></li>'
            
         }
        
     })

     
</script>

my view.py


def get_names(request):
    search = request.GET.get('search')
    payload = []
    if search:
        objs = Names.objects.filter(name__startswith=search)
        for obj in objs:
            payload.append({
            'name' : obj.name
            })
            
    return JsonResponse({
        '200': True,
        'playload': payload  
    }) 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The problem is your javascript syntax, it's

const url = `/address/get-names/?search=${input}`

instead of

const url = "/address/get-names/?search=${input}"
about 4 years ago · Juan Pablo Isaza Denunciar
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