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

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

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 Relatório

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 Relatório

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 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