[codestyle] shortly explain why we wrap .create() in a transaction

This commit is contained in:
bronsen 2025-03-15 22:28:46 +01:00
parent aa5d19c5e5
commit 246c22ce39

View file

@ -48,6 +48,8 @@ class DetailView(generic.DetailView):
@require_http_methods(["POST"])
def enter(request: HttpRequest) -> HttpResponse:
try:
# if .create() failed, the transaction is rolled back and we are in a
# clean (database) state to handle exceptions
with transaction.atomic():
teil = Teil.objects.create(name=request.POST["new_name"])
except Exception: