Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!