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

241
Views
Creating Trigger using javascript and django

I want to make a trigger using javascript. This is my trigger in js :

setInterval(function(){
    $.ajax({
        type: 'GET',
        url : "{% url 'update_state' %}",
        success: function(response){
            
            console.log('Updated');

        },
        error: function(response){
            console.log('An error occured')
        }
    });
},60000);

And this is my view :

def update_state(request):
    requests = Request.objects.all()
    for req in requests:
        d = Request.objects.filter(id=req.id)
        dd = d.get()
        if dd.delay == timedelta(minutes=0):
            pass
        else:
            d_del = dd.delay - timedelta(minutes=1)
            d.update(delay=d_del)
    return HttpResponse('ok')

In my db sometimes the delay decrease but some time don't decrease. I don't know where is the problem.

about 4 years ago · Juan Pablo Isaza
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!