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

188
Views
Django: ¿Es necesario llamar a select_for_update para un objeto creado recientemente en una transacción atómica?

Tengo una vista con transacción atómica, donde se crea un objeto y luego se actualiza:

 def buy(request): with transaction.atomic(): # get request.user for update user = User.objects.select_for_update().get(id=request.user.id) user.order_count += 1 # get other stuff for update items = Item.objects.select_for_update().filter(sold=False) items.update(user=user) # DO I NEED select_for_update SOMEWHERE HERE FOR NEXT UPDATE? new_sell = Sell.objects.create(user=user) # some_operations() new_sell.some_field = something new_sell.save() HttpResponse('Done')

¿Es seguro actualizar objetos recién creados sin select_for_update() en transacciones atómicas?

¿O cómo implementan las personas normales select_for_update en tales casos?

Supongo que esto será 100% seguro, pero no parece un buen plan:

 new_sell = Sell.objects.create(user=user) sell = Sell.objects.select_for_update().get(id=new_sell.id) # Now we can do everything with sell object
about 4 years ago · Santiago Trujillo
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!