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

151
Vistas
Could not parse the remainder: ',' from ''twitter:source_delete','

I want to append td to my table using ajax but I have a little problem, how to add the source.twitter_id in url?? the error that I got is "Could not parse the remainder: ',' from ''twitter:source_delete',' "

I tried also {% url 'twitter:source_delete', source.twitter_id %} it also error.

javascript

function appendToUsrTable(source) {
console.log(source.twitter_id)
    $("#sourceTable > tbody:last-child").append(`
         <tr class="record" id="source-${source.twitter_id}">
          <td>{{forloop.counter}}</td>
          <td>${source.source_acct}</td>
          <td><p data-placement="top" data-toggle="tooltip" title="Delete"><a href="{% url 
            'twitter:source_delete' ${source.twitter_id} %}" class="source_delete btn btn-
             danger btn-xs" 
             data-title="Delete" data-toggle="modal" data-target="#delete"><span class="las la-trash-alt 
 del_s"></span></a></p></td>
       </tr>
`);

}

views.py

class CreateCrudUser(View):
def  get(self, request):
    
    name_source = request.GET.get('source_acct', None)
    print(name_source)
    obj = Source.objects.create(
        source_acct = name_source
        )

    source = {'twitter_id':obj.twitter_id,'source_acct':obj.source_acct}

    data = {
    'source': source
    }
    return JsonResponse(data)
 
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

this problem is raising because empty(null value) of source.twitter_id so it is better to check if source.twitter_id is null or not

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can try to define the url variable outside of java script template literal like this :

function appendToUsrTable(source) {
    const url = "{% url 'twitter:source_delete' source.twitter_id %}"
    console.log(source.twitter_id)
    $("#sourceTable > tbody:last-child").append(`
         <tr class="record" id="source-${source.twitter_id}">
           <td>{{forloop.counter}}</td>
           <td>${source.source_acct}</td>
           <td><p data-placement="top" data-toggle="tooltip" title="Delete"><a href=${url} class="source_delete btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#delete"><span class="las la-trash-alt del_s"></span></a></p></td>
         </tr>
`);

NB : be careful about combine Django template variable with Java Script template literal.

about 4 years ago · Juan Pablo Isaza Denunciar

0

I found a solution. thank you!

let sour = source.twitter_id;
var url = "{% url 'twitter:source_delete' 123 %}".replace(/123/,sour.toString());
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