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

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