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

127
Views
same user Sending multiple post api request at same time and we are trying to add new data with old data in database

But some how the there is no consistency in output. some time you will see in console there is two consecutive "inside post" and some time some time you will see one time two time consecutive "after save method" printed in console. Data also saved in database there no consistency. One solution I can think of before same user was sending many post request at same time by clicking single button now I am thinking after clicking button first request should go and after frontend got respond second request should send post request and so on. If you have better approach please suggest

@csrf_exempt
def product_rest(request,pk):
    product=Product.objects.get(pk=pk)    
        if request.method == "POST":
            status = True
            code = 200
            message = ""
            data = []
            print("inside post")
                parsed_data=json.loads(request.body)
                print("parsing data == ", parsed_data)
            
                try:
                    db_time = json.loads(product.time)
                    print("old data ==",db_time)
                    db_time.append(parsed_data)
                    db_time_tostring=json.dumps(db_time)
                    print("after adding data == ", db_time_tostring)
                    product.time=db_time_tostring
                    product.save()
                    print(" after save method == ", product.time)
                    message = "Order status created"
                except:
                    status = False
                    code = 500
                    message = "Internal server error"

        return JsonResponse({
            "status": status,
            "code": code,
            "message": message,
            "data": data
        })
about 4 years ago · Santiago Gelvez
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!