Atomic increment of a counter in django
Atomic increment of a counter in django Question: I’m trying to atomically increment a simple counter in Django. My code looks like this: from models import Counter from django.db import transaction @transaction.commit_on_success def increment_counter(name): counter = Counter.objects.get_or_create(name = name)[0] counter.count += 1 counter.save() If I understand Django correctly, this should wrap the function in a …