Skip to content

Instantly share code, notes, and snippets.

@uday12kumar
Created January 28, 2020 12:31
Show Gist options
  • Save uday12kumar/c5c98572a236669f11127d39eda32dfb to your computer and use it in GitHub Desktop.
Save uday12kumar/c5c98572a236669f11127d39eda32dfb to your computer and use it in GitHub Desktop.
@classmethod
def book(cls, id, seats_selected):
with transaction.atomic():
if seats < self.seats_selected:
raise errors.InsufficientSeats()
slot = (cls.objects.select_for_update().get(id=id))
slot.seats -= seats_selected
slot.save()
return slot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment